Given a tree
We define the valley graph of the tree as
Let us construct a tree
The first line of input consists of two integers
Output one line for each query of type 2 - containing a single integer, the shortest path in
Subtask # | Score | Constraints |
---|---|---|
1 | 6 | |
2 | 10 | |
3 | 12 | |
4 | 15 | All type 1 queries occur before all type 2 queries. The tree |
5 | 12 | The tree |
6 | 20 | All type 1 queries occur before all type 2 queries. |
7 | 25 | No additional constraints |
Sample Input 1 | Sample Output 1 |
7 10
|
4
|
In this sample input, the final layouts of the tree
The shortest path in
The shortest path in
The shortest path in
One shortest path in
Sample Input 2 | Sample Output 2 |
10 20
|
2
|
Sample Input 3 | Sample Output 3 |
10 20
|
2
|
Subtask | Score |
---|---|
1 | 6 |
2 | 10 |
3 | 12 |
4 | 15 |
5 | 12 |
6 | 20 |
7 | 25 |
8 | 0 |