QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#471148#6396. Puzzle: KusabiUESTC_DebugSimulatorWA 26ms10768kbC++172.6kb2024-07-10 18:36:582024-07-10 18:36:58

Judging History

你现在查看的是最新测评结果

  • [2024-07-10 18:36:58]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:10768kb
  • [2024-07-10 18:36:58]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lowbit(i) (i&-i)
#define rand() (myrand())
using namespace std;
mt19937 myrand(time(0));
const int maxn = 2e5 + 5;
int n, _, head[maxn], cnt;
int c[maxn], dep[maxn], jud, fa[maxn];
string ty;
vector<pair<int, int> >ans;
struct node{
	int next, to;
}edge[maxn<<1];
void addedge(int from, int to) {
	edge[++cnt].next = head[from];
	edge[cnt].to = to;
	head[from] = cnt;
}
bool cmp(int x, int y) {return dep[x] < dep[y];}
int dfs(int u, int p) {
	if (jud) return 0;
	dep[u] = dep[p] + 1;
	vector<int>a[3];
	if (c[u] != -1) a[c[u]].push_back(u);
	for (int i = head[u] ; i ; i = edge[i].next) {
		int v = edge[i].to;
		if (v == p) continue;
		int x = dfs(v, u);
		if (c[x] != -1) a[c[x]].push_back(x);
	}
	sort(a[0].begin(), a[0].end(), cmp);
	sort(a[1].begin(), a[1].end(), cmp);
	sort(a[2].begin(), a[2].end(), cmp);
	int len0 = a[0].size(), len1 = a[1].size(), len2 = a[2].size(), res = 0, cnt = 0, pos = 0;
	while(pos < len0) {
		vector<int>stk;
		stk.push_back(a[0][pos]);
		while(pos + 1 < len0 && dep[a[0][pos + 1]] == dep[a[0][pos]]) {
			pos++;
			stk.push_back(a[0][pos]);
		}
		int tot = stk.size();
		if (tot >= 2) {
			for (int i = 0 ; i < (tot - (tot&1)) ; i += 2) ans.push_back({stk[i], stk[i + 1]});
		}
		if (tot&1) {
			cnt++;
			res = stk[tot - 1];
		}
		pos++;
	}
	int i, j;
	if (len1 < len2) {
		for (i = len2 - 1, j = len1 - 1 ; i >= 0 && j >= 0 ; --i) {
			if (dep[a[1][j]] > dep[a[2][i]]) {
				ans.push_back({a[1][j], a[2][i]});
				j--;
			}
			else {
				res = a[2][i];
				cnt++;
			}
		}	
		if (!i) res = a[2][i], cnt++;
		if (!j) res = a[1][j], cnt++;
	}
	else {
		for (i = 0, j = 0 ; i < len1 && j < len2 ; ++i) {
			if (dep[a[1][i]] > dep[a[2][j]]) {
				ans.push_back({a[1][i], a[2][j]});
				j++;
			}
			else {
				res = a[1][i];
				cnt++;
			}
		}
		if (i == len1 - 1) res = a[1][i], cnt++;
		if (j == len2 - 1) res = a[2][j], cnt++;
	}
	if (cnt > 1) {
		jud = 1;
		return 0;
	}
	return res;
}
void solve() {
	cin >> n;
	for (int i = 0 ; i <= n ; ++i) c[i] = -1;
	for (int i = 1 ; i < n ; ++i) {
		int x, p;
		cin >> x >> p >> ty;
		fa[x] = p;
		if (ty[0] != '-') {
			if (ty[0] == 'T') c[x] = 0;
			if (ty[0] == 'C') c[x] = 1;
			if (ty[0] == 'D') c[x] = 2; 
		}
		addedge(x, p);
		addedge(p, x);
	}
	if (dfs(1, 0)) jud = 1;
	if (jud) {
		cout << "NO" << '\n';
		return;
	}
	cout << "YES" << '\n';
	for (auto [x, y] : ans) {
		cout << x << ' ' << y << '\n';
	}
}
signed main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7744kb

input:

8
2 1 -
3 1 -
4 2 Tong
5 2 Tong
6 3 Duan
7 3 -
8 7 Chang

output:

YES
8 6
5 4

result:

ok Correct.

Test #2:

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

input:

10
2 1 Duan
3 2 Duan
4 2 -
5 4 Chang
6 2 Chang
7 1 Duan
8 6 Tong
9 6 Tong
10 3 Chang

output:

YES
9 8
10 3
6 2
5 7

result:

ok Correct.

Test #3:

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

input:

2
2 1 Tong

output:

NO

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 26ms
memory: 9692kb

input:

100000
2 1 Duan
3 1 Duan
4 3 -
5 4 Duan
6 3 -
7 4 Duan
8 4 -
9 8 -
10 7 Duan
11 9 -
12 7 Duan
13 7 Duan
14 8 Duan
15 13 -
16 10 Duan
17 11 Duan
18 12 -
19 1 Duan
20 5 Duan
21 4 Duan
22 14 Duan
23 16 -
24 22 Duan
25 16 Duan
26 13 -
27 13 -
28 17 -
29 5 Duan
30 22 -
31 23 -
32 9 Duan
33 5 -
34 30 Duan...

output:

YES
78961 61327
79617 28763
40169 25684
49361 25045
60228 24156
97603 50185
72206 56901
41848 10579
76635 73900
73042 50152
47346 25325
91464 63312
91034 79886
53651 27084
20428 10551
98200 36927
80157 69283
78977 68167
33135 10332
87866 40003
10826 10300
83126 81993
61240 63025
51469 32742
33688 26...

result:

ok Correct.

Test #5:

score: 0
Accepted
time: 15ms
memory: 9640kb

input:

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

output:

YES
61365 54260
94528 66883
80746 52379
57632 25539
86270 70587
50931 10692
46315 46038
51215 3973
42355 40468
31649 28057
57657 73329
66814 26291
29098 21998
93763 45470
84353 54966
74078 41071
30942 25774
51936 59287
82007 9388
40293 8527
97856 57690
76507 67337
58992 76115
76631 90319
86905 51620...

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 26ms
memory: 9652kb

input:

100000
2 1 -
3 2 -
4 3 Duan
5 4 Chang
6 5 Duan
7 6 Chang
8 7 Duan
9 8 Chang
10 9 Duan
11 10 Chang
12 11 Duan
13 12 Chang
14 12 Duan
15 14 Chang
16 15 Tong
17 15 Tong
18 17 Duan
19 18 Duan
20 19 Chang
21 18 Duan
22 21 Duan
23 18 Chang
24 21 -
25 24 Duan
26 25 Chang
27 26 Duan
28 27 Chang
29 26 Duan
3...

output:

YES
37 31
42 40
68 64
203 173
196 150
820 771
777 744
809 803
810 799
778 552
556 528
446 374
423 345
920 772
708 570
524 510
682 649
610 588
652 660
587 397
433 396
503 291
686 641
645 549
536 529
478 429
348 321
294 286
323 284
316 282
307 279
376 341
530 501
1160 1152
1757 1446
1685 1435
1428 141...

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 18ms
memory: 9604kb

input:

100000
2 1 -
3 2 -
4 3 -
5 4 -
6 5 -
7 6 -
8 7 -
9 8 -
10 9 Duan
11 10 -
12 11 Chang
13 12 Duan
14 13 Chang
15 14 -
16 15 -
17 16 Duan
18 17 Chang
19 17 -
20 19 -
21 20 -
22 21 -
23 22 -
24 23 -
25 24 -
26 25 Duan
27 26 -
28 27 Duan
29 28 -
30 29 Chang
31 28 -
32 31 Chang
33 32 -
34 32 -
35 34 -
36 ...

output:

YES
131 126
185 174
216 197
189 173
181 163
160 151
144 138
199 169
218 207
255 223
290 287
262 260
359 291
545 489
372 362
468 320
315 306
286 279
247 244
660 603
809 758
902 784
762 708
786 751
779 746
775 663
763 756
716 658
675 589
686 648
591 566
613 582
655 621
711 643
579 562
628 560
690 577
...

result:

ok Correct.

Test #8:

score: 0
Accepted
time: 21ms
memory: 9680kb

input:

100000
2 1 -
3 2 -
4 3 -
5 4 -
6 5 Duan
7 6 -
8 7 -
9 8 -
10 9 Chang
11 10 -
12 11 Duan
13 12 Chang
14 13 -
15 14 Duan
16 15 Chang
17 16 -
18 17 -
19 18 Duan
20 19 -
21 20 -
22 21 -
23 22 Chang
24 23 -
25 24 Duan
26 25 -
27 26 Chang
28 27 -
29 28 -
30 29 -
31 30 Duan
32 31 -
33 32 -
34 33 -
35 34 -
...

output:

YES
161 155
251 249
292 277
430 424
381 368
383 353
386 380
429 422
493 490
532 528
545 526
551 534
540 531
556 555
665 661
642 641
650 639
646 638
624 622
625 621
614 612
630 627
629 615
609 598
706 700
725 718
820 786
875 873
852 835
909 903
865 857
866 850
813 802
810 801
772 770
698 696
780 694
...

result:

ok Correct.

Test #9:

score: 0
Accepted
time: 19ms
memory: 10520kb

input:

100000
2 1 -
3 2 -
4 3 -
5 4 -
6 5 Duan
7 6 -
8 7 -
9 8 Chang
10 9 -
11 10 Duan
12 11 -
13 12 Chang
14 13 Duan
15 14 -
16 15 Chang
17 16 -
18 17 Duan
19 18 -
20 19 Chang
21 20 Duan
22 21 Chang
23 22 -
24 23 Duan
25 24 Chang
26 25 Duan
27 26 -
28 27 -
29 28 Chang
30 29 Duan
31 30 Chang
32 31 -
33 32 ...

output:

YES
308 306
357 356
453 450
556 554
552 549
548 547
570 568
569 567
682 676
672 671
738 737
735 728
805 801
806 794
793 791
910 908
922 914
952 946
1004 991
1016 1011
1024 1014
1164 1156
1160 1153
1155 1151
1147 1140
1102 1097
1095 1094
1093 1089
1076 1075
1123 1122
1129 1125
1135 1134
1157 1154
114...

result:

ok Correct.

Test #10:

score: 0
Accepted
time: 9ms
memory: 10688kb

input:

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

output:

YES
4774 4758
12004 11802
12878 12701
14403 14425
15175 15095
16272 16218
15813 15803
16111 15960
17703 17698
18828 18616
20553 20479
22767 22709
25371 24981
24571 23807
23781 23319
28616 28570
27425 26536
29756 29047
30157 29822
29413 29383
35551 35528
34909 34775
34774 33210
33101 33062
39883 3924...

result:

ok Correct.

Test #11:

score: 0
Accepted
time: 16ms
memory: 9940kb

input:

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

output:

YES
71252 68260
93199 72829
59385 11262
56366 7114
21981 56413
85882 88219
69070 70420
70961 46636
70919 24045
53558 8534
51312 6776
47483 14730
66745 8121
42970 14466
66071 3305
86329 37873
85723 12867
39119 31531
82602 56430
87213 24828
40456 67836
99956 34098
87387 17961
91017 87569
73357 68937
6...

result:

ok Correct.

Test #12:

score: 0
Accepted
time: 17ms
memory: 9416kb

input:

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

output:

YES
89903 67589
25532 2731
68594 39272
84767 81476
71809 60781
45615 98218
13863 9592
41771 38360
67278 32307
98634 46144
70045 36895
90229 56597
87249 21515
44881 7445
99328 70645
44757 12870
70229 15488
38942 68314
31755 361
62803 53849
74966 72268
42791 38644
39590 69049
60607 31128
68719 24390
7...

result:

ok Correct.

Test #13:

score: 0
Accepted
time: 24ms
memory: 9472kb

input:

100000
2 1 Duan
3 1 Duan
4 1 Duan
5 1 Duan
6 1 Duan
7 1 -
8 1 Duan
9 1 Duan
10 1 -
11 1 Duan
12 1 -
13 1 Duan
14 1 Duan
15 1 Duan
16 1 Duan
17 1 Duan
18 2 -
19 1 Duan
20 1 Duan
21 2 -
22 2 Duan
23 1 Duan
24 1 Duan
25 1 Duan
26 1 Duan
27 2 Duan
28 1 Duan
29 2 Duan
30 1 Duan
31 2 Duan
32 1 -
33 1 Duan...

output:

YES
99565 14629
58177 8043
77249 8022
99568 7886
97191 7106
79782 6452
98265 6438
73953 52710
76068 6320
84889 5888
81286 5812
65693 41217
97669 5668
65081 5312
92388 77289
74586 71711
89733 5206
79262 4798
99789 4777
98851 84855
79617 72776
67208 4736
96692 91965
58017 4470
93682 82143
99395 98993
...

result:

ok Correct.

Test #14:

score: 0
Accepted
time: 13ms
memory: 9568kb

input:

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

output:

YES
85599 3382
95392 3013
81526 79392
90600 76883
47562 2266
92236 67095
82645 2087
94655 86680
83294 83119
98104 53700
59880 1891
94429 84824
38939 1867
86276 72196
74866 1851
73841 1832
82555 75982
52187 33013
84502 60149
94488 90018
89910 77895
87531 1798
62543 1780
50707 45755
96747 63884
96811 ...

result:

ok Correct.

Test #15:

score: 0
Accepted
time: 15ms
memory: 9168kb

input:

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

output:

YES
93600 1484
65492 1226
80577 54647
98136 87425
92548 1057
95875 90647
91502 88522
65449 864
78454 63757
57780 863
91133 79380
90975 859
94837 81087
93397 69230
63165 847
88299 841
96200 91139
83594 61658
81529 67080
96779 96324
99215 74882
99293 99183
87893 56495
78381 778
81594 44807
82056 767
8...

result:

ok Correct.

Test #16:

score: 0
Accepted
time: 19ms
memory: 9496kb

input:

100000
2 1 Duan
3 1 Duan
4 1 -
5 1 Duan
6 1 -
7 1 Duan
8 1 Duan
9 1 Duan
10 1 Duan
11 1 -
12 1 -
13 1 -
14 1 Duan
15 1 Duan
16 1 Duan
17 1 -
18 1 Duan
19 1 Duan
20 1 Duan
21 1 -
22 1 -
23 1 Duan
24 1 Duan
25 1 Duan
26 1 -
27 1 -
28 1 Duan
29 1 Duan
30 1 -
31 1 Duan
32 1 Duan
33 1 -
34 1 Duan
35 1 -
...

output:

YES
83464 705
95111 622
99954 575
92518 91152
99688 93861
92449 531
71582 528
66385 524
91774 518
96388 95679
95051 502
68161 495
92051 491
79514 71560
91617 486
92920 466
94768 456
86414 82066
71375 69375
94412 455
96222 451
92101 86461
99900 97252
86105 437
78526 436
90094 65746
93000 82699
84619 ...

result:

ok Correct.

Test #17:

score: 0
Accepted
time: 15ms
memory: 9688kb

input:

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

output:

NO

result:

ok Correct.

Test #18:

score: 0
Accepted
time: 15ms
memory: 9280kb

input:

100000
2 1 Duan
3 2 Duan
4 3 -
5 3 Duan
6 4 -
7 4 Duan
8 3 Duan
9 2 -
10 4 Duan
11 8 Duan
12 6 -
13 3 Duan
14 6 Duan
15 7 Duan
16 6 Duan
17 14 Tong
18 7 -
19 16 Duan
20 14 Duan
21 12 Duan
22 20 Duan
23 14 Duan
24 19 -
25 2 Duan
26 22 -
27 24 Duan
28 8 Duan
29 4 Duan
30 23 Duan
31 24 Duan
32 23 Duan
...

output:

NO

result:

ok Correct.

Test #19:

score: 0
Accepted
time: 17ms
memory: 9320kb

input:

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

output:

NO

result:

ok Correct.

Test #20:

score: 0
Accepted
time: 14ms
memory: 9116kb

input:

100000
2 1 Duan
3 2 Chang
4 3 -
5 4 -
6 5 -
7 6 Duan
8 7 -
9 8 Chang
10 9 Duan
11 10 Chang
12 11 -
13 12 Duan
14 13 Chang
15 13 -
16 15 -
17 15 -
18 15 Duan
19 18 -
20 19 Duan
21 19 Chang
22 20 -
23 22 -
24 21 Duan
25 23 -
26 22 -
27 25 Chang
28 26 -
29 28 Duan
30 24 Chang
31 28 -
32 23 -
33 28 -
34...

output:

NO

result:

ok Correct.

Test #21:

score: 0
Accepted
time: 15ms
memory: 9184kb

input:

100000
2 1 Duan
3 2 Chang
4 3 -
5 4 -
6 5 Duan
7 6 -
8 7 -
9 8 Chang
10 9 Duan
11 10 Chang
12 11 Duan
13 12 Chang
14 12 -
15 14 -
16 15 Duan
17 16 Chang
18 17 -
19 17 Duan
20 19 -
21 19 Chang
22 21 -
23 21 Duan
24 23 Duan
25 24 Chang
26 24 Chang
27 24 Duan
28 27 -
29 28 Chang
30 28 Duan
31 30 -
32 3...

output:

NO

result:

ok Correct.

Test #22:

score: 0
Accepted
time: 14ms
memory: 9712kb

input:

100000
2 1 Duan
3 2 Chang
4 3 Duan
5 4 -
6 5 Chang
7 6 -
8 7 Duan
9 8 -
10 9 Chang
11 10 Duan
12 11 Chang
13 12 -
14 13 Duan
15 14 -
16 15 Chang
17 16 -
18 17 Duan
19 18 -
20 19 -
21 20 -
22 21 Chang
23 22 -
24 23 Duan
25 24 Chang
26 25 -
27 26 Duan
28 27 -
29 28 Chang
30 28 Duan
31 30 -
32 31 Chang...

output:

NO

result:

ok Correct.

Test #23:

score: 0
Accepted
time: 16ms
memory: 9896kb

input:

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

output:

NO

result:

ok Correct.

Test #24:

score: 0
Accepted
time: 14ms
memory: 10768kb

input:

100000
2 1 -
3 2 -
4 3 -
5 4 -
6 5 Duan
7 6 -
8 7 Chang
9 8 -
10 9 -
11 10 -
12 11 -
13 12 -
14 13 Duan
15 14 -
16 15 Chang
17 16 -
18 17 -
19 18 -
20 19 Duan
21 20 -
22 21 -
23 22 -
24 23 Chang
25 24 -
26 25 Duan
27 26 Chang
28 27 Duan
29 28 -
30 29 -
31 30 -
32 31 Chang
33 32 Duan
34 33 -
35 34 -
...

output:

NO

result:

ok Correct.

Test #25:

score: 0
Accepted
time: 11ms
memory: 9012kb

input:

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

output:

NO

result:

ok Correct.

Test #26:

score: -100
Wrong Answer
time: 19ms
memory: 9384kb

input:

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

output:

YES
79366 9068
72497 31614
21410 19127
69468 18625
33605 65840
92410 81117
80260 23096
93039 19557
91241 9189
16050 1518
89162 36014
89118 15414
77644 13366
76327 41776
17643 1211
86897 84693
84122 54523
40472 28993
31728 58229
84054 20299
59555 19140
68266 19141
79756 8940
56400 7543
60764 28287
32...

result:

wrong output format Unexpected end of file - int32 expected