#P1264. [ICPC2017 ASIA Daejeon]Broadcast Stations
[ICPC2017 ASIA Daejeon]Broadcast Stations
题目描述
There is a network of cities where broadcast stations, broadcasting identical information, should be placed onsome cities. Each broadcast station has its own transmission power so that it can broadcast to any city within distance from it. Here, the distance between two vertices is the number of edges included in the (unique)path between them. In this problem, the network of cities is a tree with vertices each of which represents acity. For a tree with a set of vertices, we will assign a non-negative integer , called a broadcast power, to every vertex in such that every vertex with is within distance from some vertex with. Then we can regard the vertices with as broadcast stations of transmission power, and avertex with can hear the broadcast of , if is within distance from . The goal of the problem is to find an assignment of the broadcast powers of vertices in described above minimizing
For example, in Figure A.1, two cases of an assignment of broadcast powers to vertices are shown. In the case of Figure A.1 (a), only the vertex 6 has the broadcast power 4 and the other vertices have zero. Then all the vertices with the broadcast power 0 can hear the broadcast of the vertex 6. In the case of Figure A.1 (b), two vertices 3 and 9 have the broadcast powers 2 and 1, respectively. Then all the vertices with the broadcast power 0 can hear the broadcast of either the vertex 3 or 9. This case minimizes the sum of broadcast powers. Figure A.1: Two assignments of broadcast powers
输入格式
Your program is to read from standard input. The first line contains one integer representing the number of vertices of the input tree. The vertices of are numbered from 1 to .Each of the following lines contains two integers and representing an edge to connect two vertices and in
输出格式
Your program is to write to standard output. Print exactly one line which contains an integer that is the minimum sum of broadcast powers among all the possible assignments of broadcast powers to the vertices indescribed above. The following shows sample input and output for two test cases
样例
6
1 2
3 2
2 4
5 4
6 4
2
12
1 2
2 3
4 5
5 3
3 6
6 7
7 8
8 9
12 9
9 11
10 9
3