CT43871

The Selene Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the moonlit lagoon of Selene, Freya studies rows of tunnels entries. One clean number will settle the guild's oldest argument. 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 <= 1748; 0 <= m <= 1748.

Example 1:

Input: 1089 1560 170 729 1058 688 576 452 428 230 816 792 624 250 89 906 773 504 933 785 414 392 722 298 831 557 509 846 248 143 928 693 107 623 395 435 901 258 786 196 228 972 328 742 695 686 466 361 1037 892 278 909 270 48 23 155 77 936 698 979 1040 193 996 99 112 1048 409 437 787 700 982 529 210 618 940 647 570 513 797 720 548 209 323 338 1006 739 694 1086 5 1031 541 634 931 255 658 411 910 112 924 108 309 214 623 402 657 278 489 432 441 286 488 706 47 781 640 257 20 222 165 107 444 53 352 714 187 542 928 158 622 704 536 351 410 844 1061 908 867 592 303 425 342 627 714 424 718 309 892 139 728 820 23 382 635 654 439 427 31 22 988 1036 1040 604 25 923 775 902 194 1007 299 703 354 232 1062 387 1013 661 635 465 654 790 137 874 238 814 260 932 140 696 818 541 1017 478 968 37 639 459 650 702 790 848…
Output: YES

Example 2:

Input: 1102 1133 154 572 547 219 373 580 16 349 357 685 260 330 647 615 200 163 705 306 354 828 862 65 823 13 16 409 424 721 1023 438 85 888 716 468 366 614 552 583 628 1058 545 933 165 952 95 513 375 231 28 871 391 271 368 56 422 896 1078 217 534 379 677 166 1007 210 286 28 435 491 884 769 356 688 336 635 31 706 189 316 645 470 273 928 217 855 189 203 761 84 381 983 634 1045 508 279 262 569 586 792 371 583 898 424 836 490 72 413 15 785 139 124 442 551 446 1076 291 935 60 577 563 99 44 916 531 164 573 472 972 831 386 128 318 218 202 152 396 150 463 658 612 578 770 210 494 694 632 850 877 1021 484 240 271 226 1011 47 247 1099 235 312 518 208 941 397 545 663 498 560 853 989 9 954 580 477 836 915 182 300 512 468 280 517 653 575 435 322 91 156 361 85 211 852 369 420 882 893 125 301 268 803 471 329 1 …
Output: YES

Example 3:

Input: 1598 771 1261 882 10 898 1469 1150 813 1577 1127 743 78 209 1366 875 162 1236 444 616 1453 1142 365 656 1074 1443 339 845 1472 876 863 339 1378 371 1438 1171 615 936 260 15 1004 1243 291 1212 463 1307 779 365 1090 1062 1278 678 333 1317 1071 504 937 1097 1200 442 907 1164 1567 691 1520 43 91 549 305 1073 458 900 1229 1172 964 19 1067 691 883 1129 236 1308 1147 1384 1021 917 247 1002 1030 943 269 931 1282 1096 1031 1149 1215 154 529 41 750 107 1208 446 368 1500 584 66 770 1591 936 559 516 1027 1056 202 1122 171 1101 1106 823 1405 395 927 109 878 280 152 465 924 651 919 1209 512 29 363 1483 655 357 1274 745 252 1560 1176 741 1439 130 86 350 664 1361 865 1026 617 1006 617 1117 1195 1004 1289 1014 38 1158 1073 183 942 724 931 686 1256 717 856 438 819 1513 1583 913 996 842 270 1414 411 249 1515…
Output: YES

Constraints:

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

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