CT50097

Archivist's tunnels Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the coastal hub of Tidewater close for winter, Archivist must finish the tunnels ledger - one figure at a time. Task: Print YES if the directed graph contains a cycle, otherwise NO. Input format: First line: n and m. Next m lines: u v (directed). Output format: Print YES or NO. Constraints: 1 <= n <= 1820; 0 <= m <= 1820.

Example 1:

Input: 1442 1423 200 257 1375 123 112 917 1156 1105 39 845 274 1344 919 1381 886 44 411 1333 1019 9 408 1219 1171 517 346 1343 466 226 1047 693 936 722 812 288 1369 1040 542 708 1024 423 1053 1082 1232 1421 1141 466 1313 677 1214 463 1317 1136 374 470 245 198 16 904 553 771 262 1417 931 1270 630 825 89 24 780 433 106 816 528 611 1373 992 470 571 1385 346 752 854 738 1068 768 899 1410 616 709 1052 832 152 1096 162 1037 57 973 82 434 149 95 373 723 515 1050 694 623 1370 910 2 1279 1350 541 240 98 356 138 12 448 1310 850 826 1432 436 433 1143 722 359 829 499 358 602 984 1436 88 387 879 1313 92 383 447 322 10 585 610 303 860 479 372 1056 1061 620 200 165 259 1225 895 1012 1215 1385 894 305 1115 133 383 341 352 866 407 1227 871 378 991 695 56 817 962 6 1107 1401 42 268 1223 475 631 1306 1379 119 622 1…
Output: YES

Example 2:

Input: 184 1771 170 70 23 161 96 56 151 77 108 47 38 16 102 52 10 115 7 177 51 117 162 184 159 91 74 60 166 150 144 3 141 17 53 63 135 19 114 103 121 59 74 109 176 31 65 37 46 172 22 89 96 13 142 93 157 50 48 34 126 27 140 96 161 55 25 38 19 151 12 50 8 163 125 157 85 67 37 77 170 90 127 73 178 145 160 109 15 167 144 98 100 101 161 40 168 1 50 13 25 75 79 115 164 183 143 99 38 154 149 184 12 68 76 48 173 12 116 67 80 11 21 65 18 127 89 25 68 67 3 148 171 33 81 154 105 104 109 48 65 116 25 114 80 160 161 94 85 27 26 57 159 76 182 137 42 169 104 79 140 166 108 15 25 29 162 145 79 61 124 107 23 7 117 74 28 179 147 24 156 61 22 11 27 169 158 143 179 101 50 86 108 134 59 108 166 58 3 21 46 86 139 162 90 27 12 82 114 159 30 130 148 42 162 52 22 8 184 145 3 65 105 170 5 121 11 94 168 100 178 104 40 101 …
Output: YES

Example 3:

Input: 667 1576 182 132 256 472 237 8 227 163 54 172 629 234 184 401 26 105 168 249 83 46 90 602 395 627 456 430 304 212 191 177 363 441 43 658 284 525 358 501 517 594 243 592 350 172 152 613 82 328 479 129 111 379 336 129 524 294 563 624 202 300 15 117 391 252 138 516 170 334 21 607 617 534 118 581 476 631 154 371 378 564 263 341 523 286 280 547 112 661 256 525 549 566 115 406 355 37 70 446 7 398 522 529 592 149 177 605 241 390 136 153 542 76 300 619 292 186 413 10 249 435 354 94 279 391 56 165 572 225 329 665 208 616 90 253 128 363 143 572 179 587 263 492 439 23 639 114 12 208 191 104 58 184 167 370 163 260 575 318 484 152 362 609 173 436 143 170 39 394 77 518 142 667 263 369 373 648 227 453 21 584 150 450 135 545 538 4 282 226 482 340 3 391 469 532 105 229 464 449 545 467 583 225 633 230 468 4…
Output: YES

Constraints:

1 <= n <= 1820; 0 <= m <= 1820.

Loading...
Test Cases:No test cases
No test cases available.
Archivist's tunnels Reckoning - MEDIUM Coding Problem | CodeTikki