#P1395. 会议
会议
Description
There is a village with villagers, connected by paths so that all homes are connected. Each path has length . The village head wants to hold a meeting at some villager’s home. He wants the sum of distances from all villagers to the meeting place to be minimal. Which villager’s home should be chosen, and what is the minimum total distance? If multiple nodes meet the condition, choose the node with the smallest index.
Input Format
The first line contains an integer , the number of villagers.
The next lines each contain two integers and , indicating that there is a path between villager and villager .
Output Format
Output two integers and in one line.
Here, is the villager’s home where the meeting will be held.
is the minimum possible sum of distances.
4
1 2
2 3
3 4
2 4
Hint
Constraints
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号