CT40692

The Zigzag corridors of Clerk

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the terraced vines of Grapehollow, Clerk records each corridors in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1167; 0 <= m <= 1167.

Example 1:

Input: 928 317 288 876 68 762 708 803 694 751 232 798 868 361 377 117 138 331 752 725 293 695 793 664 709 251 88 357 446 456 853 422 832 433 770 578 637 503 104 531 456 834 564 307 107 874 407 869 13 292 392 444 171 304 173 583 731 772 189 110 138 579 849 534 531 870 53 861 373 25 321 7 146 260 350 520 329 869 554 838 495 570 584 425 439 360 542 23 581 209 391 17 241 852 119 407 51 182 731 380 527 756 347 928 137 561 709 640 190 316 878 46 430 792 459 249 94 784 863 312 725 866 249 923 240 698 409 665 928 245 146 489 521 618 628 212 817 339 663 401 147 347 763 898 519 239 888 92 779 598 513 593 882 69 153 809 455 668 546 454 334 365 92 595 207 64 38 808 604 635 224 275 135 145 844 808 52 675 714 56 241 615 252 491 123 625 723 476 670 409 886 462 161 415 391 655 153 732 331 455 311 162 553 282 113…
Output: NO

Example 2:

Input: 854 1017 282 542 733 697 808 687 59 93 200 503 837 83 5 669 333 5 142 241 417 212 808 546 392 23 696 65 221 624 574 217 267 12 492 645 788 701 304 237 835 437 299 439 179 598 672 18 228 532 630 196 113 672 384 351 200 516 501 26 415 557 296 320 566 405 418 436 326 536 562 787 322 87 5 765 498 36 826 359 305 786 602 681 188 345 96 639 616 652 226 421 595 408 263 839 840 551 324 539 620 245 544 357 628 574 397 356 133 525 243 259 788 521 128 234 133 76 784 618 414 815 457 515 603 510 184 331 740 406 643 360 823 815 376 228 726 434 183 258 683 602 176 194 267 753 541 97 540 672 575 327 806 681 144 219 489 557 849 709 364 410 461 401 285 486 248 563 749 564 168 696 788 547 14 50 591 30 684 809 457 606 678 360 697 370 188 72 511 135 450 380 235 249 353 517 164 274 712 122 251 20 379 300 317 430…
Output: YES

Example 3:

Input: 962 1004 175 890 322 385 441 350 745 129 687 427 580 433 449 26 742 379 186 541 405 596 705 639 845 329 680 928 224 33 100 605 117 53 854 191 563 33 921 482 817 384 494 848 887 149 197 959 169 664 122 729 811 536 426 481 794 810 565 291 505 491 907 613 750 805 305 680 758 450 285 698 184 377 432 710 504 273 362 190 49 628 547 333 576 527 743 510 349 473 407 144 404 684 712 168 140 448 211 108 186 900 532 600 726 827 38 863 70 293 493 127 72 581 835 428 229 520 262 668 756 810 639 846 919 939 507 355 428 923 777 402 73 401 354 859 864 798 160 217 324 741 516 205 594 426 22 831 333 80 787 257 788 440 276 45 373 393 952 106 87 135 100 609 466 816 467 666 156 107 393 363 156 898 174 188 529 807 532 90 100 737 365 777 428 677 842 754 812 70 65 909 123 828 361 496 856 939 687 880 940 187 111 833…
Output: YES

Constraints:

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

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