CT37488

Admiral's bridges Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the salmon ladder of Rushing Falls pays by the answer, and Admiral intends to earn it. First: the full register of bridges. 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 <= 1312; 0 <= m <= 1312.

Example 1:

Input: 1070 227 593 229 570 909 556 24 963 609 262 963 487 716 739 423 1061 300 416 708 133 105 498 1025 164 388 596 218 298 1040 918 212 900 964 957 785 705 968 576 967 884 874 816 591 406 1041 800 143 367 479 361 873 1065 722 662 984 802 376 753 782 890 348 796 818 437 906 921 244 275 112 389 359 779 593 534 761 726 115 951 141 1004 721 197 645 557 1029 757 919 1032 967 1042 478 846 436 1030 749 425 431 964 714 834 379 153 22 980 731 692 613 1012 746 782 1067 34 91 263 944 181 208 217 501 344 748 775 286 958 747 267 415 1018 740 827 766 735 458 956 706 899 434 352 405 1009 861 625 743 848 233 899 931 906 389 380 606 586 159 374 344 717 728 434 740 790 596 783 720 1012 678 1026 33 637 391 281 78 517 345 657 747 828 53 266 465 1031 1035 915 367 886 543 406 899 771 708 559 432 614 559 425 129 855 …
Output: NO

Example 2:

Input: 949 462 347 190 226 832 387 614 252 910 86 896 34 114 150 68 840 864 122 97 98 145 259 608 308 666 279 293 769 522 10 737 780 703 275 706 550 311 29 261 422 302 133 315 736 114 886 15 447 545 204 756 700 34 636 597 343 35 92 323 149 447 654 618 543 929 586 5 119 818 147 1 339 486 426 741 926 732 315 777 291 264 705 667 7 755 243 127 803 310 841 232 554 393 945 912 176 900 527 652 542 11 601 452 161 763 372 218 96 478 551 782 719 74 441 87 135 326 597 868 602 97 656 388 152 409 868 654 424 321 298 938 929 106 241 855 808 87 902 139 175 409 355 806 15 388 149 593 105 650 663 358 19 248 34 241 884 800 822 910 228 210 657 743 743 101 388 349 194 526 422 582 932 736 549 9 400 573 360 78 755 17 23 737 325 530 373 788 628 697 176 614 949 675 722 243 368 732 750 669 8 367 132 76 744 148 547 321 81…
Output: NO

Example 3:

Input: 1194 751 704 559 479 1004 555 447 590 143 103 925 232 1147 138 103 185 15 985 445 473 125 14 811 232 352 764 545 120 1070 1007 1036 608 1053 1025 799 504 584 82 84 515 774 20 1050 275 293 464 457 949 221 1175 889 223 975 499 671 278 373 508 391 171 547 643 391 354 316 453 1130 1013 37 726 494 359 184 933 353 278 604 503 238 703 984 970 505 606 360 1092 371 1078 409 294 814 1029 653 743 507 240 921 384 1021 350 787 83 1152 1190 1175 263 814 1045 581 1124 597 175 340 416 1182 112 95 49 522 1159 1194 78 560 1046 369 89 432 948 88 552 19 312 438 831 610 1013 798 712 314 523 354 815 923 981 943 909 294 979 130 352 232 116 301 181 874 1167 375 212 722 851 160 394 15 210 270 952 877 270 523 1118 1018 945 739 811 152 547 262 344 1001 752 896 25 545 703 686 778 891 669 575 1155 59 80 455 740 808 73…
Output: YES

Constraints:

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

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