From http://blog.csdn.net/shuangde800
Source:
UV HDU
Question
A tree with N nodes numbered 0 ~ N-1, vertex is 0
Each edge has a weight.
Alice and Bob start at the vertex and go down to the leaf node.
For the first time, Bob chooses the child node to go to, and for the second time, Alice takes turns...
Each time you walk through an edge, you will get the corresponding weight. Bob wants the larger the total weight of the path, the better, and Alice wants the smaller the better.
Each time they choose the optimal solution.
The final total weight must be within the range [L, R.
What is the maximum weight Bob wants in the end?
Ideas
F (u, 0) indicates the maximum value of the U point selected by Bob.
F (u, 1) indicates the maximum value of the U point selected by Alice.
Tot (u) indicates the sum of the weights from vertex to vertex I.
W (u, v) indicates the Edge Weight of the connection points u and v.
So
F (u, 0) = max {f (V, 1) + W (u, v) | V is the son node of U & L <= f (V, 1) + W (u) + Tot (u) <= r}
F (u, 1) = min {f (v, 0) + W (u, v) | V is the son node of U & L <= f (v, 0) + W (u) + Tot (u) <= r}
The final answer is F (0, 0)
In addition, when submitting an HDU question, C ++ can be used for AC, but G ++ is used for TLE. I don't know why.
Submissionerr is used to submit the request in the request, and then ask the administrator of the request, saying that the system problem cannot be solved for the time being...
Code