100 atcoder#AGC009D. Uninity
Uninity
Score : points
Problem Statement
We will recursively define uninity of a tree, as follows: (Uni is a Japanese word for sea urchins.)
- A tree consisting of one vertex is a tree of uninity .
- Suppose there are zero or more trees of uninity , and a vertex . If a vertex is selected from each tree of uninity and connected to with an edge, the resulting tree is a tree of uninity .
It can be shown that a tree of uninity is also a tree of uninity , and so forth.
You are given a tree consisting of vertices. The vertices of the tree are numbered through , and the -th of the edges connects vertices and .
Find the minimum such that the given tree is a tree of uninity .
Constraints
- The given graph is a tree.
Input
The input is given from Standard Input in the following format:
:
Output
Print the minimum such that the given tree is a tree of uninity .
7
1 2
2 3
2 4
4 6
6 7
7 5
2
A tree of uninity consisting of vertices , , and can be constructed from the following: a tree of uninity consisting of vertex , a tree of uninity consisting of vertex , a tree of uninity consisting of vertex , and vertex .
A tree of uninity consisting of vertices and can be constructed from the following: a tree of uninity consisting of vertex , and vertex .
A tree of uninity consisting of vertices , , , , , and can be constructed from the following: a tree of uninity consisting of vertex , , and , a tree of uninity consisting of vertex and , and vertex .
12
1 2
2 3
2 4
4 5
5 6
6 7
7 8
5 9
9 10
10 11
11 12
3