#P7565. [JOISC 2021] ビーバーの会合 2 (Day3)
[JOISC 2021] ビーバーの会合 2 (Day3)
Description
You are given a tree with vertices. There is one person at each vertex, and they want to hold a secret meeting.
Suppose a secret meeting has participants, and these people are located at vertices . If a vertex minimizes the following value among all vertices (where is the distance between vertices and , and does not need to satisfy ):
then vertex is called expected. The expected value of the meeting is the number of expected vertices in the whole tree.
For each , find the maximum possible expected value of a meeting with exactly participants.
Input Format
The first line contains an integer , the number of vertices in the tree.
Each of the next lines contains two integers , representing an edge.
Output Format
Output lines, each containing one integer. The -th line should contain the answer when the meeting has participants.
5
1 2
2 3
4 2
3 5
1
4
1
2
1
7
1 2
2 3
3 4
4 5
2 6
3 7
1
5
1
3
1
2
1
Hint
Explanation of Sample 1
Below we denote .
Using the tree in Sample 1 as an example, suppose the participants are the person at vertex and the person at vertex . Then:
- , .
- .
- .
- .
- .
- .
. The vertices that satisfy the condition are , so the expected value of this meeting is .
Constraints
This problem uses bundled testdata.
- Subtask 1 (4 pts): .
- Subtask 2 (16 pts): .
- Subtask 3 (80 pts): No special constraints.
For of the data, , .
Notes
Translated from The 20th Japanese Olympiad in Informatics Spring Training Camp, Day3 C ビーバーの会合 2 (Meetings 2) English version.
Translated by ChatGPT 5
京公网安备 11011102002149号