TopCoder

Thumb qz2vnqoblj6vp6q
miku
https://chino.taipei

User's AC Ratio

100.0% (2/2)

Submission's AC Ratio

75.0% (3/4)

Description

 

Input Format

 

Output Format

 

Sample Input

10 5
1 2 1
2 3 1
2 4 1
1 5 1
2 6 1
2 7 1
5 8 1
7 9 1
1 10 1
3 1
2 1
8 1
3 1
4 1

Sample Output

0
1
4
5
6

Hints

 N<=10^5,Q<=10^5.


这棵树上所有点的度数不超过20.且1<=N,Q

Problem Source

ZJOI 2015

Subtasks

For Testdata: 0 ~ 4, Score: 100
No. Time Limit (ms) Memory Limit (KiB) Output Limit (KiB)
0 6000 262144 262144
1 6000 262144 262144
2 6000 262144 262144
3 6000 262144 262144
4 6000 262144 262144