TopCoder

Adrien Wu
$ \begin{align} AC \times 2^9 \\ \text{New TIOJ ?} \end{align} $

User's AC Ratio

40.0% (4/10)

Submission's AC Ratio

12.9% (8/62)

Tags

Description

Input Format

Output Format

Sample Input 1

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

Sample Output 1

10 9 3 0 7 0 0 9 0 0 0 0

Sample Input 2

5
1 2
2 3
3 4
4 5
9 10 0 14 10
8
2 3 4 3 2 2 3 2

Sample Output 2

10 14 0 0 0 19 0 0

Sample Input 3

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

Sample Output 3

6 4 1 12 9

Hints

Problem Source

110 學年度全國資訊學科能力競賽模擬賽

Subtasks

No. Testdata Range Constraints Score
1 0~2 範例測資。 0
2 3~13 N, Q <= 5000 7
3 14~21 ans > 0, tree generated randomly 12
4 22~32 tree is a chain 22
5 3~64 N, Q <= 10^ 5 59

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 3000 524288 65536 1
1 3000 524288 65536 1
2 3000 524288 65536 1
3 3000 524288 65536 2 5
4 3000 524288 65536 2 5
5 3000 524288 65536 2 5
6 3000 524288 65536 2 5
7 3000 524288 65536 2 5
8 3000 524288 65536 2 5
9 3000 524288 65536 2 5
10 3000 524288 65536 2 5
11 3000 524288 65536 2 5
12 3000 524288 65536 2 5
13 3000 524288 65536 2 5
14 3000 524288 65536 3 5
15 3000 524288 65536 3 5
16 3000 524288 65536 3 5
17 3000 524288 65536 3 5
18 3000 524288 65536 3 5
19 3000 524288 65536 3 5
20 3000 524288 65536 3 5
21 3000 524288 65536 3 5
22 3000 524288 65536 4 5
23 3000 524288 65536 4 5
24 3000 524288 65536 4 5
25 3000 524288 65536 4 5
26 3000 524288 65536 4 5
27 3000 524288 65536 4 5
28 3000 524288 65536 4 5
29 3000 524288 65536 4 5
30 3000 524288 65536 4 5
31 3000 524288 65536 4 5
32 3000 524288 65536 4 5
33 3000 524288 65536 5
34 3000 524288 65536 5
35 3000 524288 65536 5
36 3000 524288 65536 5
37 3000 524288 65536 5
38 3000 524288 65536 5
39 3000 524288 65536 5
40 3000 524288 65536 5
41 3000 524288 65536 5
42 3000 524288 65536 5
43 3000 524288 65536 5
44 3000 524288 65536 5
45 3000 524288 65536 5
46 3000 524288 65536 5
47 3000 524288 65536 5
48 3000 524288 65536 5
49 3000 524288 65536 5
50 3000 524288 65536 5
51 3000 524288 65536 5
52 3000 524288 65536 5
53 3000 524288 65536 5
54 3000 524288 65536 5
55 3000 524288 65536 5
56 3000 524288 65536 5
57 3000 524288 65536 5
58 3000 524288 65536 5
59 3000 524288 65536 5
60 3000 524288 65536 5
61 3000 524288 65536 5
62 3000 524288 65536 5
63 3000 524288 65536 5
64 3000 524288 65536 5