CT37301

The Painted routes of Odin

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the cedar groves of Balmcrest, Odin studies rows of routes 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 <= 1639; 0 <= m <= 1639.

Example 1:

Input: 104 1161 100 93 91 1 36 61 65 103 20 10 37 78 72 79 34 58 33 32 54 90 69 49 20 82 77 94 82 72 94 67 60 79 15 38 94 74 71 55 82 63 91 89 39 26 44 80 15 30 27 24 89 24 13 68 18 79 91 43 33 5 52 1 70 102 18 68 18 5 43 7 28 5 101 86 70 10 56 33 70 57 69 38 62 42 68 77 95 70 49 103 63 72 73 87 27 101 18 25 41 16 21 55 61 22 36 10 35 91 63 92 81 90 54 35 63 30 77 25 57 32 91 60 63 100 28 45 59 54 25 26 75 99 35 70 18 33 22 3 75 29 55 30 79 6 52 4 42 101 45 87 54 50 59 65 12 83 26 28 83 47 73 90 29 98 11 44 37 84 45 33 66 21 103 96 97 53 67 63 64 6 71 32 75 71 96 68 27 51 7 59 68 86 4 68 48 16 68 57 21 84 21 4 62 11 31 18 34 72 80 85 40 12 61 93 85 99 26 49 39 11 89 74 19 55 88 85 9 2 86 85 38 10 96 81 21 54 51 76 13 35 16 67 6 55 79 82 25 45 83 34 23 84 50 88 75 92 25 56 61 3 7 65 14 102 4 1 43 …
Output: YES

Example 2:

Input: 1077 148 769 947 356 638 104 116 267 346 315 1069 820 876 1071 1017 712 791 10 441 858 184 987 855 337 995 31 579 975 440 716 807 581 67 318 772 736 92 707 44 214 795 174 794 17 419 61 940 35 184 102 786 983 71 766 1060 336 38 932 893 700 490 1064 164 199 1022 826 749 393 653 24 50 567 452 293 411 617 664 192 288 971 401 70 765 1073 694 522 1021 647 581 34 1071 686 892 636 926 332 662 451 553 723 392 899 495 528 987 250 238 444 841 683 63 396 681 125 34 396 246 891 802 831 639 846 966 434 107 662 643 1019 1065 887 77 341 68 509 1011 23 499 256 253 805 65 766 863 787 310 773 895 541 192 89 797 602 619 368 475 198 953 259 409 377 551 684 951 266 1073 801 643 220 105 1027 951 111 425 391 607 824 1000 718 624 672 890 384 389 101 297 1074 41 284 3 658 208 659 483 315 398 660 745 652 44 247 606 …
Output: NO

Example 3:

Input: 781 877 522 214 567 487 586 118 685 486 409 360 752 575 510 373 136 437 577 378 109 561 46 402 55 33 632 80 655 496 123 85 745 217 499 222 330 310 188 103 262 387 552 428 605 685 404 6 219 52 187 355 738 388 470 325 729 616 655 405 404 516 344 501 318 518 687 516 669 228 264 36 566 94 254 699 361 367 195 765 759 360 430 735 73 30 20 714 456 358 151 712 385 436 203 359 390 548 265 687 401 26 617 502 74 209 101 69 640 481 504 152 612 192 657 197 59 468 596 567 80 554 485 604 752 727 513 767 423 652 176 481 294 28 181 394 580 531 221 188 649 397 415 275 776 180 555 605 666 19 643 393 774 212 7 449 27 38 680 266 217 358 684 240 62 482 732 263 746 63 10 152 452 535 504 255 126 175 378 639 432 130 570 627 107 454 583 387 172 36 33 660 156 220 151 731 152 570 109 628 438 344 406 535 61 146 507 22…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Painted routes of Odin - MEDIUM Coding Problem | CodeTikki