# TopCoder

Caido
$\mathbb{W}\mathcal{aimai}\sim %Wow, you found an easter egg!!!$

97.9% (47/48)

56.0% (56/100)

5 2
1 0
1 1
2 0
3 1
1 1
1 3

2
2
1

10 0
1 0
1 1
2 0
3 0
3 1
2 1
5 0
4 0
6 1

1

# Hints

(如果你知道什麼是二元樹及前中後序遍歷，你可以安全地跳過這段)

# Problem Source

No. Testdata Range Constraints Score
1 0~1 範例測資 0
2 2~6 $n \leq 1000, q = 0$ 10
3 2~13 $q = 0$ 15
4 2~6, 14~20 $n, q \leq 1000$ 15
5 2~27 無其他限制 60

# Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 2000 262144 65536 1
1 2000 262144 65536 1
2 2000 262144 65536 2 3 4 5
3 2000 262144 65536 2 3 4 5
4 2000 262144 65536 2 3 4 5
5 2000 262144 65536 2 3 4 5
6 2000 262144 65536 2 3 4 5
7 2000 262144 65536 3 5
8 2000 262144 65536 3 5
9 2000 262144 65536 3 5
10 2000 262144 65536 3 5
11 2000 262144 65536 3 5
12 2000 262144 65536 3 5
13 2000 262144 65536 3 5
14 2000 262144 65536 4 5
15 2000 262144 65536 4 5
16 2000 262144 65536 4 5
17 2000 262144 65536 4 5
18 2000 262144 65536 4 5
19 2000 262144 65536 4 5
20 2000 262144 65536 4 5
21 2000 262144 65536 5
22 2000 262144 65536 5
23 2000 262144 65536 5
24 2000 262144 65536 5
25 2000 262144 65536 5
26 2000 262144 65536 5
27 2000 262144 65536 5