CT49082

The Windward corridors of Wren

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the fen lights of Will-o-Wisp close for winter, Wren must finish the corridors 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 <= 3517; 0 <= m <= 3517.

Example 1:

Input: 2755 3139 1953 2635 1455 1751 69 82 2025 1601 307 1412 1111 1598 380 111 193 2464 326 1996 314 2285 1436 1049 2299 1159 533 995 1788 2240 1378 2714 2609 2041 583 966 1384 2311 2274 515 2396 1339 2449 1279 2127 2551 1638 238 604 1226 580 1409 160 955 320 849 197 500 118 2408 1702 48 2410 1305 1900 734 2443 15 2446 1226 2625 219 1676 1564 2393 2138 1024 873 923 2563 1667 1299 2045 2049 919 1013 1433 2215 2194 898 1270 2092 2647 565 1046 2526 731 491 900 1869 1039 1832 1767 1472 1084 799 977 1324 2479 1614 2351 1605 1396 930 1647 2664 646 1925 1051 221 889 1913 1124 312 2130 63 2008 217 446 1655 1325 666 1926 1681 1673 135 444 471 678 2251 2578 263 2317 1232 1269 1393 1337 650 1417 608 2729 1029 2663 403 1012 661 2289 1810 951 2373 873 2480 465 2326 1179 1340 639 1685 1875 1657 524 1965 2277 …
Output: YES

Example 2:

Input: 2420 1326 2030 393 2222 821 643 35 1676 1397 1591 1986 1187 910 1543 214 1206 1910 338 1582 1741 1929 244 1691 721 1868 273 1681 1576 1417 1800 1038 987 762 1743 1908 408 442 2011 317 485 1442 491 1373 1306 1087 348 185 73 1042 359 2100 1006 1468 569 288 2072 1382 1914 353 1588 1000 2211 401 786 517 2060 1027 231 2205 2362 2197 173 880 2123 1866 952 2127 584 1437 639 862 1953 1896 1571 1256 1261 1263 1384 878 2283 643 668 576 1628 2194 546 1287 2334 1625 1115 1059 498 1240 1033 1491 1021 2087 275 164 1830 1674 1968 2243 2379 779 20 2269 1830 1178 1209 400 705 1829 745 1601 669 7 1353 1409 1563 629 1975 2145 1378 14 181 2040 1825 2100 1517 248 1493 405 1606 1255 1277 1529 1466 1131 1186 1806 1127 56 2419 2014 141 1672 1069 53 2122 1751 1310 1747 2139 238 333 474 2274 2276 409 1169 1488 1511…
Output: YES

Example 3:

Input: 961 959 824 585 120 692 250 794 905 382 412 150 214 609 78 91 757 528 781 891 332 778 418 632 52 74 872 773 762 425 589 521 3 953 950 789 574 800 221 189 489 664 100 35 496 599 434 281 814 866 461 751 213 48 197 109 844 749 51 672 224 79 307 843 388 773 501 430 684 763 658 209 197 853 161 499 894 827 137 90 319 869 297 948 541 952 592 427 409 855 190 29 504 896 150 124 619 154 798 486 162 519 395 889 567 15 583 35 16 221 121 72 578 547 557 708 786 918 98 775 278 679 91 207 272 535 155 485 281 272 237 310 11 852 644 522 670 950 20 607 894 699 385 423 925 322 838 157 230 83 11 620 776 696 732 613 409 328 640 360 442 206 378 397 445 322 645 462 684 344 169 187 221 481 177 911 61 116 139 45 32 741 825 444 539 369 232 739 677 542 645 89 626 286 691 457 424 173 578 925 180 543 9 440 35 775 352 1…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Windward corridors of Wren - MEDIUM Coding Problem | CodeTikki