#P3478. [POI 2008] STA-Station
[POI 2008] STA-Station
Description
Given a tree with nodes, find a node such that when this node is chosen as the root, the sum of depths of all nodes is maximized.
The depth of a node is defined as the number of edges on the simple path from that node to the root.
Input Format
The first line contains an integer , the number of nodes in the tree.
The next lines each contain two integers , indicating that there is an edge connecting and .
Output Format
This problem uses Special Judge.
Output one line with an integer, the index of the chosen node. If multiple nodes satisfy the requirement, output any one of them.
8
1 4
5 6
4 5
6 7
6 8
2 4
3 4
7
Hint
Sample 1 Explanation:
Outputting or are both correct answers.
Constraints:
For all test points, it is guaranteed that , , and the input is a tree.
Translated by ChatGPT 5
京公网安备 11011102002149号