QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227808#6536. LawyersLainAC ✓120ms17372kbC++231.7kb2023-10-27 23:57:292023-10-27 23:57:29

Judging History

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

  • [2023-10-27 23:57:29]
  • 评测
  • 测评结果:AC
  • 用时:120ms
  • 内存:17372kb
  • [2023-10-27 23:57:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n, m;
  cin >> n >> m;
  vi p(n), s(n, 1);
  iota(all(p), 0);

  auto find = [&](auto self, int v)->int {
    if (v == p[v]) return v;
    return p[v] = self(self, p[v]);
  };

  auto merge = [&](int u, int v)->bool {
    u = find(find, u);
    v = find(find, v);
    if (u == v) return false;
    if (s[u] < s[v]) swap(u, v);
    s[u] += s[v];
    p[v] = u;
    return true;
  };

  auto norm = [&](pii&& p)->pii {
    if (p.first > p.second) return {p.second, p.first};
    return p;
  };

  set<pii> edgeset;
  set<pii> undir;
  vector<pii> edges;
  vi indeg(n);

  rep(i, 0, m) {
    int u, v;
    cin >> u >> v;
    u--,v--;
    auto e = norm(make_pair(u, v));
    if (edgeset.count(e)) {
      undir.insert(e);
    } else edgeset.insert(e);
    edges.push_back({u, v});
  }

  for (auto& e : edges) {
    if (undir.count(norm(std::forward<pii>(e))))
      continue;
    indeg[e.second]++;
  }

  vector<int> is_ok(n);
  for (auto& e : undir) {
    if (!merge(e.first, e.second)) {
      is_ok[e.first] = is_ok[e.second] = 1;
    }
    if (indeg[e.first] > 0 || indeg[e.second] > 0) {
      is_ok[e.first] = is_ok[e.second] = 1;
    }
  }

  rep(i, 0, n) is_ok[find(find, i)] |= is_ok[i];

  bool ok = true;
  rep(i, 0, n) {
    if (find(find, i) == i && indeg[i] == 0) {
      ok &= is_ok[i];
    }
  }
  cout << (ok?"YES":"NO") << '\n';
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

3 3
1 2
2 3
3 1

output:

YES

result:

ok answer is YES

Test #2:

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

input:

4 6
1 2
1 3
1 4
2 3
2 4
3 4

output:

NO

result:

ok answer is NO

Test #3:

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

input:

4 4
1 2
2 1
3 4
4 3

output:

NO

result:

ok answer is NO

Test #4:

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

input:

4 6
1 2
2 1
1 3
3 1
1 4
4 1

output:

NO

result:

ok answer is NO

Test #5:

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

input:

4 7
1 2
2 1
1 3
3 1
1 4
4 1
2 4

output:

YES

result:

ok answer is YES

Test #6:

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

input:

5 12
2 4
3 1
3 4
1 2
4 2
2 3
5 4
1 3
1 4
4 1
3 2
4 3

output:

NO

result:

ok answer is NO

Test #7:

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

input:

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

output:

YES

result:

ok answer is YES

Test #8:

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

input:

100 381
24 54
59 3
49 33
42 18
1 91
59 10
49 18
60 45
32 99
80 85
48 63
87 29
11 87
99 84
60 17
86 78
79 69
33 13
89 53
60 50
33 9
91 9
44 16
34 13
10 81
6 93
99 95
59 56
47 58
92 94
38 15
90 76
9 76
92 20
91 2
40 94
1 44
33 29
50 47
39 8
23 72
3 70
76 56
72 30
30 9
31 95
87 74
32 26
65 99
26 63
47 ...

output:

NO

result:

ok answer is NO

Test #9:

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

input:

200 2138
125 98
98 191
135 17
13 15
195 87
144 13
173 189
146 142
158 112
35 128
90 146
19 199
176 144
100 193
86 58
83 130
107 29
171 25
75 60
73 121
55 3
17 121
66 107
104 29
173 34
167 18
139 87
175 158
182 90
103 189
8 10
80 117
11 93
2 108
82 36
92 172
29 196
192 102
49 22
132 51
142 119
178 13...

output:

YES

result:

ok answer is YES

Test #10:

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

input:

300 1810
142 139
73 164
275 139
116 189
116 4
162 128
135 218
206 86
280 82
105 283
264 11
189 255
129 154
279 70
264 242
31 100
166 73
204 86
16 288
57 91
39 227
26 156
217 71
285 213
206 67
121 169
31 183
18 282
263 16
95 271
253 122
110 92
295 148
68 1
198 160
167 99
147 4
294 154
179 203
204 90
...

output:

NO

result:

ok answer is NO

Test #11:

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

input:

400 2748
47 87
211 61
161 227
188 90
10 1
252 135
363 389
196 379
6 296
169 30
194 198
117 128
395 207
388 387
191 278
216 252
2 133
342 6
395 295
71 158
165 317
152 168
239 266
250 329
364 215
82 395
68 271
330 188
97 52
302 367
227 216
400 329
189 165
277 389
389 86
118 369
88 252
48 319
179 281
2...

output:

YES

result:

ok answer is YES

Test #12:

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

input:

500 3281
260 32
198 38
397 52
491 172
328 418
254 250
125 310
348 335
227 470
439 285
368 266
182 280
43 13
277 66
364 226
357 184
468 58
136 431
155 36
41 141
457 303
398 430
439 209
305 144
436 345
64 163
473 112
78 74
394 340
179 229
31 108
472 112
39 187
205 311
97 308
189 148
46 371
409 458
61 ...

output:

NO

result:

ok answer is NO

Test #13:

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

input:

600 3065
562 373
436 322
75 541
363 69
418 210
255 553
561 181
438 527
349 184
503 533
306 345
518 250
413 462
268 484
303 99
262 278
481 445
209 378
114 42
68 395
67 127
87 215
516 217
100 125
564 92
197 75
292 551
589 410
500 502
5 144
54 327
513 445
478 30
553 574
496 145
145 478
330 3
9 544
405 ...

output:

YES

result:

ok answer is YES

Test #14:

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

input:

700 4314
578 417
111 99
115 462
262 452
444 224
261 72
118 606
493 575
363 649
577 387
480 514
92 606
461 680
456 369
81 91
102 355
140 688
343 535
251 466
461 165
447 143
292 645
671 381
689 605
397 321
150 326
396 243
433 138
493 336
501 621
394 243
540 219
250 285
119 268
212 473
424 217
539 408
...

output:

NO

result:

ok answer is NO

Test #15:

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

input:

800 4676
84 66
54 295
501 150
233 353
634 132
162 76
343 277
775 468
293 759
228 331
418 701
520 675
335 732
261 278
208 624
499 607
367 757
685 447
730 78
370 440
673 641
517 661
697 376
654 225
59 673
216 555
325 336
145 40
216 760
12 625
568 534
34 65
752 6
428 760
107 203
171 187
572 363
769 369...

output:

YES

result:

ok answer is YES

Test #16:

score: 0
Accepted
time: 3ms
memory: 3988kb

input:

900 6315
600 106
37 469
437 868
537 27
459 745
764 194
304 706
127 524
11 429
2 485
96 54
393 631
679 243
744 354
594 16
47 777
723 808
214 307
271 710
258 310
553 756
634 192
647 344
535 9
792 402
569 510
317 827
784 769
308 490
3 298
512 150
60 539
827 49
490 558
331 432
454 418
85 260
467 221
165...

output:

NO

result:

ok answer is NO

Test #17:

score: 0
Accepted
time: 3ms
memory: 3900kb

input:

1000 6270
29 498
348 695
192 495
436 840
39 109
732 751
435 808
183 996
232 762
818 946
358 71
552 376
330 26
647 497
723 263
825 524
605 599
292 700
369 887
794 928
411 600
778 20
315 369
629 7
837 449
921 563
785 741
650 177
755 704
748 114
676 718
298 470
599 704
763 225
277 315
591 729
497 736
1...

output:

YES

result:

ok answer is YES

Test #18:

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

input:

2000 19638
750 1078
1088 1516
1826 420
564 1811
779 1796
1928 782
245 1065
658 845
1151 412
715 98
478 1483
1986 1300
871 1860
1207 493
1864 255
273 428
1199 833
169 1892
1841 1690
1501 187
773 1304
734 1676
535 1441
962 1989
661 638
1682 1754
1781 202
125 176
573 791
308 1267
522 841
492 1488
1130 ...

output:

YES

result:

ok answer is YES

Test #19:

score: 0
Accepted
time: 10ms
memory: 4924kb

input:

3000 23894
2766 2169
1829 1041
2052 537
988 2486
224 2378
2908 109
2952 2218
2236 1694
71 1959
2020 1738
301 2382
227 1632
1412 591
1279 1490
1901 1438
2617 525
2306 364
238 381
2017 1685
2399 2446
239 1008
1202 2140
2458 1810
2590 2868
486 2019
851 1841
1074 559
2496 1392
1200 1174
867 908
2768 166...

output:

YES

result:

ok answer is YES

Test #20:

score: 0
Accepted
time: 20ms
memory: 6024kb

input:

4000 51690
514 913
688 1479
3379 2490
2994 1515
384 2044
2904 822
649 1548
3732 736
1716 2181
2206 2534
1514 1541
1010 1478
88 846
3501 2247
3280 2822
1556 2159
3077 2679
109 3979
2834 336
835 490
1556 194
1766 162
555 3
873 3242
2717 1294
2947 3966
371 3810
3278 1343
59 1471
2987 3824
3300 3372
604...

output:

NO

result:

ok answer is NO

Test #21:

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

input:

5000 42849
4183 750
3907 658
4790 2294
1111 3833
2306 2066
2627 3239
2893 3320
2228 4307
3090 3554
4560 2626
4115 2758
4122 3963
1646 3606
4922 1364
1483 3232
2978 651
2616 4023
586 605
2277 1080
3948 2042
2840 1382
1688 2919
4859 399
2042 3035
3713 1301
4463 4442
3996 4462
2692 2933
1498 2413
647 1...

output:

YES

result:

ok answer is YES

Test #22:

score: 0
Accepted
time: 25ms
memory: 6572kb

input:

6000 61116
3251 4184
170 3122
456 4532
547 1649
377 1722
1568 2372
5166 2766
890 3730
1747 2186
2112 2326
457 1851
981 31
979 1219
621 2240
5354 998
2052 3456
3482 4445
5862 1068
674 646
1736 3008
4088 1601
2190 386
4995 4660
1939 1399
5775 1273
5172 5244
3661 731
1829 558
5504 2748
5402 4210
1792 5...

output:

NO

result:

ok answer is NO

Test #23:

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

input:

7000 56206
199 6931
6281 6682
120 1836
4529 5693
197 3162
3347 5073
833 6127
5924 625
4701 1341
4100 4618
3929 1325
1826 1295
1583 1620
2269 2238
4065 6217
3827 776
4926 873
4229 5125
1833 1771
3689 6638
1442 4861
2879 4889
2963 773
5 201
1235 3584
2267 2340
3111 4070
4376 6987
5796 6948
3131 1045
6...

output:

YES

result:

ok answer is YES

Test #24:

score: 0
Accepted
time: 41ms
memory: 7712kb

input:

10000 83928
3629 6645
7208 4066
573 8765
5940 1053
4440 8746
5801 8503
1556 8432
8160 9413
8474 8629
9827 4832
1913 1366
7828 1460
1650 1153
503 2388
1597 3529
6115 1668
1396 6934
7765 3262
8643 8562
5228 2734
2094 8140
6894 3686
6395 6729
3458 1867
9795 8878
6804 4885
4518 9991
3701 675
1748 8036
8...

output:

NO

result:

ok answer is NO

Test #25:

score: 0
Accepted
time: 120ms
memory: 14316kb

input:

20000 199939
14477 10814
1347 18225
28 16551
4289 255
7288 13185
6601 7807
13092 5437
1441 17555
14088 49
19860 15427
19666 1845
12238 19897
18961 13543
19076 8772
8248 6055
18473 6553
4289 2075
9306 493
7047 14924
5524 4892
16714 6120
2296 8390
5679 17854
8301 16268
1470 17861
7742 16023
2818 11989...

output:

NO

result:

ok answer is NO

Test #26:

score: 0
Accepted
time: 102ms
memory: 14424kb

input:

30000 199982
21107 19697
18718 13258
4398 26382
423 11848
14668 5755
16161 2999
81 29594
24338 14488
9383 17023
8341 15621
9224 22371
17318 11398
5301 28836
6154 23901
26370 25346
4837 2475
1303 14996
27729 10504
27313 2385
18333 4143
10878 17608
16956 10351
20757 25288
2258 29547
8108 15816
6667 11...

output:

NO

result:

ok answer is NO

Test #27:

score: 0
Accepted
time: 98ms
memory: 15492kb

input:

100000 199999
4168 90309
35924 83986
32421 41854
30603 48261
15805 90131
22396 91846
88152 14649
63409 57981
25473 60041
42585 58101
92297 60257
51397 26619
94181 97762
4460 15205
99691 48016
79143 24649
90265 18198
23925 24993
92814 89631
58425 68590
94319 58654
37367 76370
14019 83495
56474 94740
...

output:

NO

result:

ok answer is NO

Test #28:

score: 0
Accepted
time: 96ms
memory: 16372kb

input:

150000 199999
136184 107558
36656 123390
112483 49352
92387 143837
101219 38692
100861 112483
61654 30389
112991 99117
66957 123354
20236 123740
31824 91991
41581 59606
8152 2482
116014 44163
79364 143318
121166 9984
123236 27523
84643 73584
31969 113660
60836 87702
135267 39095
43165 104460
20729 1...

output:

NO

result:

ok answer is NO

Test #29:

score: 0
Accepted
time: 100ms
memory: 17184kb

input:

190000 199998
53076 160943
160590 177799
130495 131679
33974 54997
182969 18293
84820 6894
30385 109637
60298 90440
56684 122743
176413 184031
19487 38935
141125 151807
20598 60694
47601 189691
70401 18631
18657 167065
89633 37459
96874 15828
114592 57221
22694 59049
178150 138767
184033 177130
3459...

output:

NO

result:

ok answer is NO

Test #30:

score: 0
Accepted
time: 101ms
memory: 17212kb

input:

200000 199997
105764 5960
28891 160305
79920 106216
145439 12714
171093 46186
45262 35736
181696 34724
191095 83013
11392 181
166347 198464
197195 177150
4129 158942
177400 116708
1778 83316
73347 115088
155997 195166
97997 176366
107940 109180
186521 168241
18862 10543
62544 166094
51779 174816
150...

output:

NO

result:

ok answer is NO

Test #31:

score: 0
Accepted
time: 50ms
memory: 17292kb

input:

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

output:

YES

result:

ok answer is YES

Test #32:

score: 0
Accepted
time: 61ms
memory: 17228kb

input:

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

output:

YES

result:

ok answer is YES

Test #33:

score: 0
Accepted
time: 65ms
memory: 17296kb

input:

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

output:

NO

result:

ok answer is NO

Test #34:

score: 0
Accepted
time: 62ms
memory: 17372kb

input:

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

output:

NO

result:

ok answer is NO

Test #35:

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

input:

100 201
1 2
2 1
2 3
3 2
1 4
4 1
1 5
5 1
3 6
6 3
1 7
7 1
5 8
8 5
8 9
9 8
4 10
10 4
8 11
11 8
11 12
12 11
1 13
13 1
9 14
14 9
6 15
15 6
11 16
16 11
17 18
18 17
18 19
19 18
19 20
20 19
17 21
21 17
21 22
22 21
20 23
23 20
23 24
24 23
19 25
25 19
22 26
26 22
17 27
27 17
22 28
28 22
20 29
29 20
23 30
30 2...

output:

YES

result:

ok answer is YES

Test #36:

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

input:

100 202
1 2
2 1
1 3
3 1
2 4
4 2
2 5
5 2
1 6
6 1
1 7
7 1
7 8
8 7
4 9
9 4
5 10
10 5
5 11
11 5
7 12
12 7
8 13
13 8
9 14
14 9
12 15
15 12
4 16
16 4
17 18
18 17
17 19
19 17
19 20
20 19
20 21
21 20
20 22
22 20
19 23
23 19
23 24
24 23
23 25
25 23
25 26
26 25
26 27
27 26
23 28
28 23
27 29
29 27
22 30
30 22
...

output:

NO

result:

ok answer is NO

Test #37:

score: 0
Accepted
time: 45ms
memory: 9336kb

input:

50000 100001
1 2
2 1
1 3
3 1
1 4
4 1
3 5
5 3
3 6
6 3
3 7
7 3
3 8
8 3
8 9
9 8
2 10
10 2
2 11
11 2
6 12
12 6
3 13
13 3
5 14
14 5
4 15
15 4
13 16
16 13
10 17
17 10
16 18
18 16
3 19
19 3
15 20
20 15
10 21
21 10
1 22
22 1
15 23
23 15
12 24
24 12
3 25
25 3
13 26
26 13
5 27
27 5
4 28
28 4
13 29
29 13
8 30
...

output:

YES

result:

ok answer is YES

Test #38:

score: 0
Accepted
time: 38ms
memory: 9344kb

input:

50000 100086
1 2
2 1
1 3
3 1
1 4
4 1
4 5
5 4
1 6
6 1
2 7
7 2
6 8
8 6
3 9
9 3
2 10
10 2
8 11
11 8
10 12
12 10
3 13
13 3
8 14
14 8
11 15
15 11
3 16
16 3
13 17
17 13
9 18
18 9
14 19
19 14
4 20
20 4
7 21
21 7
16 22
22 16
18 23
23 18
13 24
24 13
2 25
25 2
3 26
26 3
7 27
27 7
27 28
28 27
17 29
29 17
2 30
...

output:

NO

result:

ok answer is NO

Test #39:

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

input:

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

output:

YES

result:

ok answer is YES

Test #40:

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

input:

50000 99999
1 2
2 1
1 3
3 1
2 4
4 2
3 5
5 3
3 6
6 3
1 7
7 1
5 8
8 5
2 9
9 2
2 10
10 2
2 11
11 2
3 12
12 3
8 13
13 8
5 14
14 5
2 15
15 2
5 16
16 5
3 17
17 3
16 18
18 16
1 19
19 1
12 20
20 12
11 21
21 11
10 22
22 10
9 23
23 9
22 24
24 22
1 25
25 1
6 26
26 6
3 27
27 3
2 28
28 2
9 29
29 9
24 30
30 24
25...

output:

NO

result:

ok answer is NO

Test #41:

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

input:

50000 100003
1 2
2 1
1 3
3 1
3 4
4 3
3 5
5 3
3 6
6 3
6 7
7 6
2 8
8 2
1 9
9 1
9 10
10 9
2 11
11 2
9 12
12 9
8 13
13 8
6 14
14 6
2 15
15 2
13 16
16 13
8 17
17 8
8 18
18 8
7 19
19 7
1 20
20 1
15 21
21 15
16 22
22 16
13 23
23 13
8 24
24 8
9 25
25 9
17 26
26 17
10 27
27 10
2 28
28 2
12 29
29 12
27 30
30 ...

output:

YES

result:

ok answer is YES

Test #42:

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

input:

50000 99996
1 2
2 1
2 3
3 2
1 4
4 1
2 5
5 2
4 6
6 4
3 7
7 3
2 8
8 2
6 9
9 6
2 10
10 2
10 11
11 10
8 12
12 8
4 13
13 4
5 14
14 5
14 15
15 14
15 16
16 15
4 17
17 4
1 18
18 1
4 19
19 4
7 20
20 7
19 21
21 19
9 22
22 9
15 23
23 15
3 24
24 3
18 25
25 18
15 26
26 15
25 27
27 25
6 28
28 6
12 29
29 12
20 30
...

output:

NO

result:

ok answer is NO

Test #43:

score: 0
Accepted
time: 47ms
memory: 9360kb

input:

50000 99997
1 2
2 1
2 3
3 2
2 4
4 2
1 5
5 1
2 6
6 2
4 7
7 4
7 8
8 7
2 9
9 2
7 10
10 7
9 11
11 9
2 12
12 2
1 13
13 1
11 14
14 11
14 15
15 14
15 16
16 15
1 17
17 1
3 18
18 3
4 19
19 4
11 20
20 11
16 21
21 16
3 22
22 3
14 23
23 14
20 24
24 20
9 25
25 9
21 26
26 21
21 27
27 21
6 28
28 6
23 29
29 23
5 30...

output:

YES

result:

ok answer is YES

Test #44:

score: 0
Accepted
time: 40ms
memory: 9536kb

input:

50000 99996
1 2
2 1
2 3
3 2
2 4
4 2
2 5
5 2
4 6
6 4
6 7
7 6
1 8
8 1
7 9
9 7
4 10
10 4
2 11
11 2
4 12
12 4
7 13
13 7
4 14
14 4
8 15
15 8
8 16
16 8
4 17
17 4
1 18
18 1
8 19
19 8
10 20
20 10
20 21
21 20
4 22
22 4
1 23
23 1
5 24
24 5
13 25
25 13
3 26
26 3
15 27
27 15
18 28
28 18
22 29
29 22
16 30
30 16
...

output:

NO

result:

ok answer is NO

Test #45:

score: 0
Accepted
time: 47ms
memory: 9488kb

input:

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

output:

YES

result:

ok answer is YES

Test #46:

score: 0
Accepted
time: 49ms
memory: 11340kb

input:

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

output:

YES

result:

ok answer is YES

Test #47:

score: 0
Accepted
time: 50ms
memory: 12196kb

input:

70000 140096
1 2
2 1
1 3
3 1
3 4
4 3
3 5
5 3
5 6
6 5
2 7
7 2
4 8
8 4
5 9
9 5
6 10
10 6
10 11
11 10
7 12
12 7
9 13
13 9
6 14
14 6
8 15
15 8
6 16
16 6
12 17
17 12
12 18
18 12
15 19
19 15
3 20
20 3
9 21
21 9
15 22
22 15
8 23
23 8
5 24
24 5
23 25
25 23
6 26
26 6
6 27
27 6
7 28
28 7
5 29
29 5
16 30
30 16...

output:

NO

result:

ok answer is NO

Test #48:

score: 0
Accepted
time: 54ms
memory: 12164kb

input:

70000 139902
1 2
2 1
2 3
3 2
1 4
4 1
4 5
5 4
5 6
6 5
1 7
7 1
1 8
8 1
5 9
9 5
5 10
10 5
1 11
11 1
2 12
12 2
7 13
13 7
8 14
14 8
5 15
15 5
10 16
16 10
2 17
17 2
3 18
18 3
12 19
19 12
12 20
20 12
13 21
21 13
3 22
22 3
15 23
23 15
8 24
24 8
7 25
25 7
11 26
26 11
7 27
27 7
8 28
28 8
6 29
29 6
20 30
30 20...

output:

YES

result:

ok answer is YES

Test #49:

score: 0
Accepted
time: 60ms
memory: 12184kb

input:

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

output:

NO

result:

ok answer is NO

Test #50:

score: 0
Accepted
time: 68ms
memory: 12192kb

input:

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

output:

YES

result:

ok answer is YES

Test #51:

score: 0
Accepted
time: 69ms
memory: 12108kb

input:

70000 139996
1 2
2 1
1 3
3 1
2 4
4 2
1 5
5 1
2 6
6 2
3 7
7 3
5 8
8 5
4 9
9 4
2 10
10 2
4 11
11 4
8 12
12 8
4 13
13 4
3 14
14 3
3 15
15 3
3 16
16 3
15 17
17 15
8 18
18 8
10 19
19 10
16 20
20 16
6 21
21 6
12 22
22 12
4 23
23 4
21 24
24 21
6 25
25 6
10 26
26 10
25 27
27 25
16 28
28 16
22 29
29 22
15 30...

output:

NO

result:

ok answer is NO

Test #52:

score: 0
Accepted
time: 67ms
memory: 12280kb

input:

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

output:

YES

result:

ok answer is YES

Test #53:

score: 0
Accepted
time: 60ms
memory: 12096kb

input:

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

output:

NO

result:

ok answer is NO

Test #54:

score: 0
Accepted
time: 62ms
memory: 12176kb

input:

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

output:

YES

result:

ok answer is YES

Test #55:

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

input:

7 23
1 2
2 3
3 4
4 5
5 1
1 4
4 2
2 5
5 3
3 1
2 1
3 2
4 3
5 4
1 5
4 1
2 4
5 2
3 5
1 3
6 1
1 7
7 6

output:

YES

result:

ok answer is YES

Test #56:

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

input:

27 161
13 8
13 5
13 26
13 9
13 25
13 2
13 11
13 20
13 15
8 13
8 5
8 26
8 9
8 25
8 2
8 11
8 20
8 15
5 13
5 8
5 26
5 9
5 25
5 2
5 11
5 20
5 15
26 13
26 8
26 5
26 9
26 25
26 2
26 11
26 20
26 15
9 13
9 8
9 5
9 26
9 25
9 2
9 11
9 20
9 15
25 13
25 8
25 5
25 26
25 9
25 2
25 11
25 20
25 15
2 13
2 8
2 5
2 26...

output:

YES

result:

ok answer is YES