CT56267

The Circular Route at Padmore

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Vigo the factor watches over the lily shoals of Padmore's stores of bridges. A careful computation stands between order and chaos. 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 <= 3153; 0 <= m <= 3153.

Example 1:

Input: 2749 1771 2140 778 2654 1788 2172 1676 509 1112 1725 2655 1364 2698 739 833 760 1803 896 1312 631 2475 1866 1534 2724 1973 1517 794 413 1491 525 846 1271 2687 1421 1824 1607 2452 2623 651 1247 1193 637 1818 2596 781 2391 2337 1812 2252 2062 2565 1469 1087 2117 2345 1572 2410 1106 1477 999 1766 2199 1566 695 608 251 1068 1529 413 1224 1043 1899 2001 2060 1288 140 2407 432 2561 2315 1998 2554 1190 1983 1739 1708 1177 2282 931 1921 1349 1488 767 1012 183 2452 2430 1620 141 155 2597 1325 2255 2266 999 1637 1640 942 2561 307 1575 1014 1730 1126 972 1942 1002 786 2331 2278 1106 842 1066 2187 1235 1500 1491 2409 2471 85 352 1925 1612 1825 2658 1557 1341 583 2589 200 2323 90 1917 294 2524 1799 2708 477 2650 2307 942 2705 1273 580 1791 2156 1110 1833 2101 1252 590 773 1860 1990 1227 1998 1025 2456 …
Output: NO

Example 2:

Input: 1872 686 340 1148 1366 1783 1829 1700 717 332 96 1308 1157 374 1827 1279 1116 350 1015 1269 1160 168 327 852 500 1798 1507 857 1789 1691 1392 796 493 1310 429 1055 1428 1298 1005 686 1137 804 401 784 1838 1842 1724 1763 751 1253 120 200 1744 1198 756 974 1342 1199 879 854 1121 492 525 273 1282 89 494 63 906 851 1467 242 1652 440 994 1159 137 1160 226 1155 1399 128 1218 666 1389 1203 1666 1215 325 604 1490 1425 1306 913 100 1120 1181 1137 1593 809 940 926 576 724 183 172 794 1487 1112 444 340 1039 208 134 143 457 212 1763 57 585 32 1151 271 1690 813 1795 1495 1509 1295 1300 1566 764 998 39 1284 449 877 212 1801 434 1597 1545 1496 944 459 102 853 739 371 1241 606 1407 630 867 990 1731 1726 476 415 542 1581 310 895 1278 737 1814 247 302 1115 1183 1483 1478 122 1786 904 749 1703 1179 630 1819 …
Output: NO

Example 3:

Input: 2762 2950 892 2075 669 1746 956 540 2685 602 2447 2387 275 1620 7 496 1393 2150 863 496 371 106 2373 143 984 887 2734 398 311 1569 1298 790 2110 2240 919 2589 614 2364 46 2424 1505 667 21 556 47 2676 935 1177 2635 1993 18 1757 365 1012 230 2670 2282 799 393 882 2478 1220 1800 1797 294 1002 1204 1852 1332 1641 2318 471 215 1761 138 1851 293 1655 1604 880 1982 435 1717 1566 1429 2480 276 1465 820 1088 1320 1705 653 2413 1277 2057 2355 499 2569 2334 2449 1714 1771 903 1145 1502 2754 1485 2393 650 1773 1198 1142 2054 2525 1449 1732 232 1299 2514 2735 1760 50 2011 1357 219 1823 1707 288 275 2223 558 1758 2628 2083 1391 1628 227 1556 2397 2223 542 1827 965 2435 1954 2389 1730 1712 1734 2609 2118 87 2717 647 1049 1407 1807 1805 2652 1356 73 1024 743 1451 668 150 414 2505 439 1809 486 1186 1417 26…
Output: YES

Constraints:

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

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