CT53196

The Circular Route at Scriptoria

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the ink district of Scriptoria close for winter, Xara must finish the routes 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 <= 2708; 0 <= m <= 2708.

Example 1:

Input: 1995 2111 1243 1553 647 671 410 468 1498 1698 674 747 31 792 203 1537 786 1021 1383 206 657 1332 1640 236 601 761 289 940 269 883 583 1517 1857 1680 291 1669 851 161 1284 811 1258 498 179 865 343 1084 1793 803 404 661 337 792 1458 980 1710 239 1611 654 1070 446 1344 925 235 1017 303 1891 182 330 1807 691 1995 1648 1513 1797 770 1042 753 103 397 1278 1632 1063 739 1127 278 1676 1661 1905 658 942 1041 584 1102 1779 1829 1627 1181 569 1056 1139 1135 1412 1947 127 637 632 1000 736 1513 844 1916 439 503 866 466 1621 869 369 184 1587 976 541 669 449 1276 1652 696 783 482 549 392 608 1802 31 943 57 1844 308 1628 1538 1917 1370 1622 1509 807 380 1769 530 1950 721 1362 1762 397 252 322 227 1554 1138 677 1011 841 1895 1610 1323 938 1328 98 276 103 1041 1794 520 1310 640 1224 970 1923 231 1625 1230 1…
Output: YES

Example 2:

Input: 124 2244 112 96 93 98 1 65 85 61 97 87 121 17 116 25 84 12 82 26 95 101 63 109 37 114 37 14 65 108 50 92 85 51 89 98 101 114 101 117 2 36 91 95 43 77 12 110 97 115 124 92 2 101 115 2 64 81 72 11 37 79 44 31 92 8 34 56 124 114 97 4 14 2 81 122 41 13 99 66 86 79 1 85 10 14 64 10 21 6 34 22 108 35 92 57 26 25 13 83 97 10 103 76 9 118 95 76 84 2 87 18 109 94 93 2 64 95 120 118 117 116 101 63 78 3 98 42 88 31 73 97 100 102 61 58 47 107 58 120 4 81 62 45 3 5 25 30 113 73 109 33 109 75 123 71 94 29 6 88 58 16 80 46 31 52 73 2 97 27 92 15 75 31 75 64 22 57 84 38 62 11 18 61 77 19 7 118 90 36 69 77 95 40 102 25 88 121 10 64 71 91 27 2 36 68 1 70 25 106 84 47 47 123 57 108 33 29 89 83 74 119 99 109 122 27 4 21 77 84 118 41 39 96 115 103 27 73 40 50 31 24 31 77 61 97 13 71 105 32 53 112 24 112 53 116…
Output: YES

Example 3:

Input: 2110 2581 1991 1610 2091 802 1266 1148 478 1841 1472 1762 1553 1066 1389 1870 195 1101 290 1189 243 1998 873 1973 194 754 1474 1895 1075 848 1711 1961 497 178 432 168 847 30 1453 1041 1190 1510 1249 1035 763 661 587 1522 34 386 641 1071 862 1079 1193 153 1528 32 1848 312 629 322 820 51 197 612 256 378 752 575 1977 1205 599 47 1209 173 297 1984 158 239 1457 99 1058 1715 1531 289 566 60 2110 1546 704 1378 1455 204 1736 317 1064 556 699 110 714 1000 351 1919 1657 266 1910 277 2041 1656 842 1139 312 2031 317 561 1609 1814 343 992 1353 1799 796 1717 446 1724 1116 447 51 1449 946 898 1091 510 1284 1713 1022 854 103 332 386 2038 1126 1690 1561 867 259 110 312 420 268 716 977 1764 534 1458 371 829 199 1090 366 1522 1679 378 1293 1775 654 1536 53 1025 444 455 867 209 1553 1157 44 1599 2047 1365 179…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Circular Route at Scriptoria - MEDIUM Coding Problem | CodeTikki