TopCoder

YenSean
Hello World!

User's AC Ratio

100.0% (6/6)

Submission's AC Ratio

40.9% (9/22)

Tags

Description

 

Input Format

 

Output Format

 

Sample Input 1

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 1

0
1
4
5
6

Hints

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


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

Problem Source

ZJOI 2015

Subtasks

No. Testdata Range Score
1 0~4 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 6000 262144 262144 1
1 6000 262144 262144 1
2 6000 262144 262144 1
3 6000 262144 262144 1
4 6000 262144 262144 1