CT43895

Obsidian routes Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the honey farms of Buzzwell pays by the answer, and Amara intends to earn it. First: the full register of routes. 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 <= 3908; 0 <= m <= 3908.

Example 1:

Input: 3756 2295 1533 1563 47 2610 2485 1053 3152 1493 96 3726 632 2607 2494 2365 2677 866 2822 2493 366 2114 308 327 749 3725 196 2120 2607 1568 2701 2535 1086 3422 2401 3239 2715 824 1722 307 1128 122 904 3604 3080 608 550 676 1086 179 3169 1106 1396 240 829 3159 1095 3119 633 1087 3552 165 1888 2728 1527 666 3025 879 2974 3089 1546 1687 373 2567 1359 1308 2785 2396 2526 3455 354 1090 3662 2819 736 797 41 3608 2922 2392 805 3054 566 3349 2255 2672 2304 2445 2624 2590 864 1744 2943 916 3238 680 79 2852 1176 2434 1681 137 3455 1386 857 638 2818 541 2305 3272 103 2287 2515 1874 664 478 1846 457 1963 658 1785 198 2399 783 816 2882 1269 905 2108 970 735 2603 2373 364 3544 539 2902 659 3051 10 2905 1822 2772 733 3572 2851 2538 922 2549 3106 2072 3756 3528 3436 1729 1121 1630 438 987 3360 2526 1841 23…
Output: NO

Example 2:

Input: 1028 43 282 888 501 713 441 197 891 601 951 707 81 133 486 133 552 287 922 882 35 669 996 385 611 147 853 84 953 504 430 829 630 298 125 279 701 770 18 448 792 470 880 987 271 11 431 296 691 123 637 689 961 43 183 591 886 973 299 302 908 1018 710 648 714 51 102 329 327 697 713 225 65 964 382 376 786 771 231 755 251 556 1020 732 256 519 48 44
Output: NO

Example 3:

Input: 2320 2769 1305 1753 1430 763 980 1144 1769 305 1797 1698 777 1031 1218 10 1533 1704 261 989 2106 1775 884 1727 783 656 640 950 2205 1962 1115 1916 118 1337 2037 1903 1271 303 312 2019 1218 597 695 5 760 669 307 1941 1326 1902 643 1230 1629 868 827 1016 1407 1516 2111 1211 1958 2019 411 1347 1317 1705 902 720 840 131 2045 2055 435 1664 294 2060 285 1926 836 1936 1393 315 1659 501 1928 1080 467 510 329 1201 288 1879 1155 831 524 1799 2298 316 1873 2276 175 30 769 1495 636 352 1244 46 332 2213 1581 2313 1888 953 1498 1978 2126 1856 753 646 1620 1051 963 1272 226 1658 1171 8 657 1188 1127 914 2144 1313 1442 206 1553 1276 1001 1465 1769 1353 600 1026 452 1598 887 1778 2242 1959 1133 2118 809 1382 1001 1157 1829 2238 110 1379 1372 635 1705 1412 1532 591 1694 2104 1207 1654 1406 1992 1174 415 990…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.