Question Link
It is to give you a tree with a certain weight for each edge, and then let you find the maximum distance that each vertex can reach.
Analysis:
This question is still a bit dizzy. I posted my analysis on it and analyzed it thoroughly.
First, we use 1 as the root node for a DFS traversal. During traversal, we can find out the maximum distance and the next distance that can be reached from the root node I to the subtree, and the two distances are not in the same branch. Then we start the DFS traversal from the root node for the second time. At this time, we need to determine that for a node I, in addition to the shortest distance in the direction of the subtree, can I use the parent node to make it farther away? For this operation, we only need to access the maximum distance that the parent node can reach, then you can connect to the node, but there is a problem -- that is, the maximum distance of the parent node may pass through the current node, therefore, we need to determine whether the current node is on the longest branch of the parent node. If so, we need to change to another branch, and if it is the farthest, in fact, this is the first time that the remote path obtained in DFS is not in the same branch as the farthest path. If the path is not transferred, then we can directly connect to the farthest path of the parent node for transfer.
HDU 2196 computer (tree DP)