CT37279

Asha and the Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the island market of Coralcove close for winter, Asha 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 <= 3162; 0 <= m <= 3162.

Example 1:

Input: 1002 2480 531 202 230 654 608 85 75 516 923 738 259 466 966 804 491 358 813 229 207 267 870 845 802 778 588 88 653 177 449 529 692 88 29 930 60 207 641 751 232 903 594 899 653 879 128 273 657 871 689 343 201 536 305 575 688 356 49 189 159 628 824 218 900 661 97 514 596 712 54 570 716 225 58 858 610 827 10 200 206 716 230 131 644 34 138 674 309 797 642 618 444 598 488 855 944 455 185 84 587 433 33 161 162 373 242 92 636 460 231 943 772 946 679 104 57 833 689 542 799 782 232 204 236 249 76 923 287 106 636 276 884 505 185 843 963 649 507 242 666 519 196 185 768 461 961 355 828 46 172 176 316 957 754 421 562 159 18 946 350 917 994 621 10 121 573 548 548 531 595 881 13 972 543 45 255 296 1002 676 281 986 927 296 950 67 56 119 779 169 349 608 674 213 19 233 845 106 432 989 763 493 55 480 140 675…
Output: YES

Example 2:

Input: 2340 409 761 418 671 641 2308 253 1313 1187 2173 754 1953 1987 996 1336 2222 2078 1037 1293 1276 1872 59 61 727 661 2241 1319 1123 843 2036 1161 2163 928 1353 275 1263 1051 669 1730 1847 2325 127 1436 1104 195 96 1585 95 757 2091 1375 1621 2143 1561 842 726 1309 2106 302 2194 1853 773 237 351 1635 1184 939 2321 2195 148 1475 821 877 375 1453 2329 2301 125 2140 1486 1615 681 1141 10 846 227 199 2215 944 1843 2325 1633 1706 230 2184 1691 1776 121 430 2025 515 28 2262 526 874 2173 339 1268 675 1405 1937 757 524 2327 1002 1760 49 314 2156 927 1057 1934 1196 629 1696 50 39 79 709 1517 1126 1391 668 292 732 1548 776 1421 796 943 2210 1260 658 1438 551 213 493 982 750 475 1493 1680 1272 783 729 1426 1270 1057 2224 1743 1461 1069 287 1902 1282 239 1237 753 1234 382 239 904 2184 436 1545 1118 549 3…
Output: NO

Example 3:

Input: 1425 908 1380 1319 667 915 35 1128 1064 1134 1399 437 157 258 792 64 1127 105 394 677 391 601 184 191 235 740 469 732 664 1094 417 375 631 761 148 1027 6 478 998 905 992 1177 493 623 374 1300 724 166 766 864 1328 728 942 1222 937 1042 63 370 1260 465 961 772 1408 1126 598 960 263 1326 140 1201 882 1218 514 615 957 233 199 1133 439 1116 804 67 879 1047 498 620 947 848 681 1404 446 703 689 1350 1299 408 1368 912 494 166 1015 947 7 909 86 464 1355 1037 1335 1412 260 1231 396 1377 504 135 1414 997 1033 900 959 882 415 1361 274 567 335 464 113 57 939 815 1313 708 891 683 687 901 921 82 23 772 241 630 195 599 77 509 682 218 449 886 408 230 1255 611 578 379 952 801 802 662 210 1173 681 739 793 282 960 419 606 1345 494 1118 1291 1403 717 843 999 1322 405 289 382 229 1067 944 1363 1220 54 440 623 6…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Asha and the Circular Route - MEDIUM Coding Problem | CodeTikki