#P15780. [JAG 2025 Summer Camp #3] Communication between islands
[JAG 2025 Summer Camp #3] Communication between islands
题目描述
Solve the following problem for .
There are islands, and with bridges it is possible to travel between any two islands.
When there is an announcement to be made to all islands, flyers are distributed in a somewhat unusual way. First, exactly one flyer is created on island . After that, the following operation is repeated:
Choose one flyer, and let be the island that currently has it. Duplicate the flyer once, and deliver the original and the duplicate (exactly two flyers in total) to islands connected to by a bridge. These two flyers may both be delivered to the same island or to two different islands.
Determine the minimum number of operations required until every island has at least one flyer.
输入格式
The input consists of a single test case in the following format.
$$\begin{aligned} & N \\ & u_1 \ v_1 \\ & \vdots \\ & u_{N-1} \ v_{N-1} \end{aligned} $$The first line contains an integer (), representing the number of islands.
The following lines each contain integers (, ), representing that the -th bridge connects island and island .
It is guaranteed that one can travel between any two islands using bridges.
输出格式
Output integers separated by spaces. The -th integer should contain the minimum number of operations when .
3
1 2
2 3
2 3 2
5
3 1
2 3
3 5
3 4
5 5 5 5 5