QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#486172#8636. 伸展树Cirno#100 ✓431ms102724kbC++141.4kb2024-07-21 17:14:002024-07-21 17:14:01

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 0ms
memory: 13916kb

input:

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

output:

No

result:

points 1.0 ok

Test #2:

score: 0
Accepted
time: 2ms
memory: 12104kb

input:

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

output:

Yes
14
10 0
9 0
8 0
5 0
3 0
5 0
8 0
8 0
9 1
5 1
4 1
6 1
3 1
1 1

result:

points 1.0 ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 12116kb

input:

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

output:

Yes
17
9 0
2 0
9 0
6 0
5 0
5 0
9 0
8 0
7 1
8 1
6 1
5 1
3 1
4 1
1 1
2 1
9 1

result:

points 1.0 ok

Subtask #2:

score: 30
Accepted

Test #4:

score: 30
Accepted
time: 0ms
memory: 12132kb

input:

1000
2 1 1
9 2 1
7 3 1
3 4 0
6 5 1
4 6 0
8 7 1
2 8 0
988 9 1
9 10 0
986 11 1
983 12 1
14 13 1
16 14 1
14 15 0
951 16 1
949 17 1
947 18 1
20 19 1
21 20 1
946 21 1
945 22 1
24 23 1
31 24 1
24 25 0
25 26 0
28 27 1
26 28 0
28 29 0
29 30 0
22 31 0
106 32 1
35 33 1
33 34 0
39 35 1
38 36 1
36 37 0
35 38 0
...

output:

Yes
1995
992 0
990 0
988 0
9 0
2 0
9 0
8 0
7 0
7 0
7 0
6 0
988 0
988 0
987 0
986 0
986 0
983 0
983 0
956 0
955 0
954 0
951 0
16 0
14 0
16 0
951 0
950 0
949 0
949 0
947 0
947 0
946 0
21 0
20 0
946 0
945 0
945 0
31 0
24 0
31 0
31 0
31 0
28 0
31 0
31 0
945 0
108 0
107 0
106 0
106 0
105 0
104 0
103 0
40...

result:

points 1.0 ok

Test #5:

score: 0
Accepted
time: 2ms
memory: 12064kb

input:

1000
2 1 1
464 2 1
4 3 1
462 4 1
441 5 1
5 6 0
8 7 1
9 8 1
11 9 1
9 10 0
440 11 1
429 12 1
14 13 1
12 14 0
428 15 1
17 16 1
18 17 1
15 18 0
20 19 1
18 20 0
22 21 1
20 22 0
22 23 0
23 24 0
24 25 0
27 26 1
28 27 1
75 28 1
66 29 1
56 30 1
32 31 1
30 32 0
34 33 1
32 34 0
49 35 1
35 36 0
38 37 1
36 38 0
...

output:

Yes
1997
1000 0
464 0
2 0
464 0
462 0
4 0
462 0
441 0
441 0
441 0
440 0
11 0
9 0
8 0
11 0
440 0
436 0
435 0
429 0
429 0
14 0
429 0
428 0
428 0
18 0
17 0
428 0
20 0
428 0
22 0
428 0
428 0
428 0
428 0
427 0
426 0
75 0
28 0
27 0
75 0
74 0
66 0
66 0
56 0
56 0
32 0
56 0
34 0
56 0
49 0
49 0
49 0
38 0
49 0...

result:

points 1.0 ok

Test #6:

score: 0
Accepted
time: 2ms
memory: 12152kb

input:

1000
34 1 1
14 2 1
4 3 1
13 4 1
4 5 0
7 6 1
8 7 1
12 8 1
10 9 1
11 10 1
8 11 0
5 12 0
2 13 0
1 14 0
33 15 1
19 16 1
16 17 0
17 18 0
30 19 1
21 20 1
22 21 1
23 22 1
19 23 0
25 24 1
26 25 1
23 26 0
28 27 1
26 28 0
28 29 0
15 30 0
32 31 1
30 32 0
14 33 0
36 34 1
34 35 0
40 36 1
36 37 0
39 38 1
37 39 0
...

output:

Yes
1995
981 0
42 0
40 0
36 0
34 0
34 0
14 0
14 0
13 0
4 0
13 0
13 0
12 0
8 0
7 0
12 0
11 0
10 0
34 0
33 0
33 0
30 0
19 0
19 0
19 0
30 0
23 0
22 0
21 0
30 0
26 0
25 0
30 0
28 0
30 0
33 0
32 0
36 0
40 0
40 0
39 0
42 0
981 0
79 0
79 0
78 0
74 0
74 0
73 0
71 0
69 0
51 0
48 0
47 0
47 0
51 0
50 0
69 0
69...

result:

points 1.0 ok

Test #7:

score: 0
Accepted
time: 1ms
memory: 10096kb

input:

1000
15 2 1
12 3 1
3 4 0
4 5 0
10 6 1
6 7 0
9 8 1
7 9 0
11 10 1
5 11 0
13 12 1
14 13 1
2 14 0
17 15 1
15 16 0
48 17 1
17 18 0
18 19 0
45 20 1
20 21 0
40 22 1
22 23 0
27 24 1
26 25 1
24 26 0
29 27 1
27 28 0
36 29 1
29 30 0
33 31 1
31 32 0
34 33 1
35 34 1
30 35 0
23 36 0
38 37 1
39 38 1
36 39 0
43 40 ...

output:

Yes
1995
1000 0
988 0
48 0
17 0
15 0
15 0
14 0
13 0
12 0
12 0
12 0
12 0
11 0
10 0
10 0
10 0
9 0
17 0
48 0
48 0
48 0
47 0
45 0
45 0
45 0
44 0
43 0
40 0
40 0
40 0
36 0
29 0
27 0
27 0
26 0
29 0
36 0
36 0
35 0
34 0
33 0
33 0
40 0
39 0
38 0
43 0
43 0
47 0
988 0
979 0
979 0
978 0
977 0
353 0
352 0
352 0
2...

result:

points 1.0 ok

Test #8:

score: 0
Accepted
time: 2ms
memory: 13860kb

input:

1000
1000 1 1
21 2 1
18 3 1
6 4 1
4 5 0
3 6 0
6 7 0
10 8 1
8 9 0
11 10 1
7 11 0
13 12 1
15 13 1
13 14 0
11 15 0
17 16 1
15 17 0
19 18 1
20 19 1
2 20 0
22 21 1
994 22 1
22 23 0
25 24 1
985 25 1
28 26 1
26 27 0
980 28 1
979 29 1
29 30 0
32 31 1
902 32 1
34 33 1
35 34 1
32 35 0
37 36 1
35 37 0
893 38 1...

output:

No

result:

points 1.0 ok

Subtask #3:

score: 40
Accepted

Test #9:

score: 40
Accepted
time: 414ms
memory: 101068kb

input:

1000000
87 1 1
71 2 1
25 3 1
15 4 1
6 5 1
7 6 1
9 7 1
7 8 0
13 9 1
9 10 0
10 11 0
11 12 0
14 13 1
4 14 0
17 15 1
15 16 0
23 17 1
19 18 1
22 19 1
21 20 1
19 21 0
17 22 0
24 23 1
3 24 0
2 25 0
31 26 1
26 27 0
29 28 1
30 29 1
27 30 0
25 31 0
41 32 1
37 33 1
35 34 1
33 35 0
35 36 0
38 37 1
39 38 1
32 39...

output:

Yes
1975823
87 0
87 0
86 0
85 0
84 0
83 0
82 0
71 0
71 0
25 0
25 0
24 0
23 0
17 0
15 0
15 0
14 0
13 0
9 0
7 0
6 0
9 0
13 0
13 0
13 0
17 0
23 0
22 0
19 0
22 0
21 0
71 0
31 0
31 0
31 0
30 0
29 0
71 0
70 0
41 0
41 0
39 0
38 0
37 0
37 0
35 0
37 0
41 0
70 0
69 0
69 0
47 0
46 0
46 0
45 0
69 0
68 0
52 0
49...

result:

points 1.0 ok

Test #10:

score: 0
Accepted
time: 42ms
memory: 23364kb

input:

100000
14747 1 1
3 2 1
14729 3 1
14725 4 1
4 5 0
25 6 1
8 7 1
22 8 1
11 9 1
9 10 0
19 11 1
18 12 1
15 13 1
13 14 0
17 15 1
15 16 0
12 17 0
11 18 0
8 19 0
19 20 0
20 21 0
23 22 1
24 23 1
6 24 0
94 25 1
25 26 0
26 27 0
92 28 1
30 29 1
28 30 0
35 31 1
33 32 1
34 33 1
31 34 0
89 35 1
35 36 0
38 37 1
39 ...

output:

Yes
199991
14939 0
14922 0
14921 0
14920 0
14918 0
14748 0
14747 0
14747 0
14732 0
14729 0
3 0
14729 0
14726 0
14725 0
14725 0
14725 0
94 0
25 0
25 0
24 0
23 0
22 0
8 0
22 0
19 0
11 0
11 0
19 0
18 0
18 0
17 0
15 0
15 0
17 0
22 0
22 0
94 0
94 0
94 0
92 0
92 0
30 0
92 0
91 0
90 0
89 0
35 0
35 0
34 0
3...

result:

points 1.0 ok

Test #11:

score: 0
Accepted
time: 39ms
memory: 23240kb

input:

100000
3 2 1
1 3 0
100000 4 1
99998 5 1
7 6 1
5 7 0
50135 8 1
50132 9 1
50130 10 1
12 11 1
16 12 1
14 13 1
12 14 0
14 15 0
23 16 1
16 17 0
22 18 1
18 19 0
21 20 1
19 21 0
17 22 0
10 23 0
25 24 1
23 25 0
27 26 1
50081 27 1
50080 28 1
30 29 1
3442 30 1
30 31 0
201 32 1
35 33 1
33 34 0
36 35 1
38 36 1
...

output:

Yes
199996
3 0
100000 0
100000 0
99998 0
99998 0
7 0
99998 0
50135 0
50135 0
50132 0
50132 0
50130 0
50130 0
23 0
16 0
12 0
16 0
14 0
16 0
23 0
23 0
22 0
22 0
22 0
21 0
50130 0
25 0
50130 0
50082 0
50081 0
27 0
50081 0
50080 0
50080 0
3442 0
30 0
3442 0
3442 0
202 0
201 0
201 0
163 0
152 0
42 0
38 0...

result:

points 1.0 ok

Test #12:

score: 0
Accepted
time: 421ms
memory: 101364kb

input:

1000000
2 1 1
2 3 0
5 4 1
10 5 1
7 6 1
8 7 1
9 8 1
5 9 0
3 10 0
26 11 1
25 12 1
16 13 1
13 14 0
14 15 0
19 16 1
16 17 0
17 18 0
20 19 1
12 20 0
22 21 1
20 22 0
22 23 0
23 24 0
11 25 0
27 26 1
28 27 1
35 28 1
31 29 1
29 30 0
32 31 1
33 32 1
34 33 1
28 34 0
10 35 0
181 36 1
36 37 0
67 38 1
38 39 0
39 ...

output:

Yes
1976575
2 0
10 0
5 0
10 0
9 0
8 0
7 0
35 0
28 0
27 0
26 0
26 0
25 0
25 0
20 0
19 0
16 0
16 0
16 0
19 0
19 0
25 0
22 0
25 0
25 0
35 0
34 0
33 0
32 0
31 0
31 0
181 0
181 0
181 0
71 0
70 0
67 0
67 0
67 0
67 0
67 0
46 0
46 0
44 0
46 0
67 0
49 0
48 0
67 0
67 0
66 0
64 0
63 0
63 0
62 0
61 0
60 0
60 0
...

result:

points 1.0 ok

Test #13:

score: 0
Accepted
time: 283ms
memory: 102672kb

input:

1000000
7 1 1
5 2 1
4 3 1
2 4 0
1 5 0
5 6 0
7 8 0
10 9 1
11 10 1
13 11 1
11 12 0
79 13 1
17 14 1
16 15 1
14 16 0
38 17 1
17 18 0
18 19 0
21 20 1
22 21 1
19 22 0
24 23 1
22 24 0
24 25 0
25 26 0
26 27 0
36 28 1
30 29 1
28 30 0
30 31 0
35 32 1
34 33 1
32 34 0
31 35 0
37 36 1
27 37 0
13 38 0
78 39 1
41 ...

output:

No

result:

points 1.0 ok

Test #14:

score: 0
Accepted
time: 431ms
memory: 102724kb

input:

1000000
2 1 1
4 2 1
2 3 0
15 4 1
11 5 1
5 6 0
8 7 1
6 8 0
8 9 0
9 10 0
12 11 1
4 12 0
14 13 1
12 14 0
40 15 1
19 16 1
16 17 0
17 18 0
23 19 1
21 20 1
22 21 1
19 22 0
24 23 1
27 24 1
24 25 0
25 26 0
15 27 0
27 28 0
39 29 1
31 30 1
29 31 0
35 32 1
32 33 0
33 34 0
36 35 1
31 36 0
36 37 0
37 38 0
28 39 ...

output:

Yes
1975904
41 0
40 0
15 0
4 0
2 0
4 0
15 0
12 0
11 0
11 0
11 0
8 0
11 0
11 0
15 0
14 0
40 0
27 0
24 0
23 0
19 0
19 0
19 0
23 0
22 0
21 0
27 0
27 0
40 0
40 0
39 0
39 0
31 0
39 0
36 0
35 0
35 0
35 0
39 0
39 0
44 0
44 0
64 0
46 0
64 0
55 0
54 0
54 0
52 0
50 0
50 0
52 0
54 0
64 0
63 0
62 0
60 0
60 0
58...

result:

points 1.0 ok