atcoder#APC001E. Antennas on Tree
Antennas on Tree
Score : points
Problem Statement
We have a tree with vertices. The vertices are numbered through , and the -th edge () comnnects Vertex and . For each pair of vertices and (), we define the distance as the number of edges in the path -.
It is expected that one of the vertices will be invaded by aliens from outer space. Snuke wants to immediately identify that vertex when the invasion happens. To do so, he has decided to install an antenna on some vertices.
First, he decides the number of antennas, (). Then, he chooses different vertices, , , ..., , on which he installs Antenna , , ..., , respectively. If Vertex is invaded by aliens, Antenna () will output the distance . Based on these outputs, Snuke will identify the vertex that is invaded. Thus, in order to identify the invaded vertex no matter which one is invaded, the following condition must hold:
- For each vertex (), consider the vector . These vectors are distinct.
Find the minumum value of , the number of antennas, when the condition is satisfied.
Constraints
- The given graph is a tree.
Input
Input is given from Standard Input in the following format:
Output
Print the minumum value of , the number of antennas, when the condition is satisfied.
5
0 1
0 2
0 3
3 4
2
For example, install an antenna on Vertex and . Then, the following five vectors are distinct:
2
0 1
1
For example, install an antenna on Vertex .
10
2 8
6 0
4 1
7 6
2 3
8 6
6 9
2 4
5 8
3
For example, install an antenna on Vertex , , .