CT35599

The Saffron Circular Route

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the crane marshes of Stillwater, Chandler the surveyor keeps careful count of the roads. Certify the cargo before shipping, every figure matters. 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 <= 1299; 0 <= m <= 1299.

Example 1:

Input: 888 696 433 696 364 779 516 316 854 634 563 416 395 815 604 620 184 209 746 292 466 502 478 16 556 603 344 823 364 35 763 588 694 25 49 771 572 314 762 572 683 416 29 843 616 545 514 335 639 439 453 714 758 201 840 751 297 416 880 61 717 463 792 114 488 564 252 649 44 280 610 157 733 231 285 191 850 357 811 160 662 391 581 608 725 555 290 197 466 379 526 79 181 138 693 220 563 301 663 203 885 563 262 220 530 454 457 219 128 587 218 290 541 615 45 127 194 731 27 608 452 822 8 812 469 639 83 51 595 245 674 133 370 855 321 18 338 231 511 600 307 127 66 249 199 512 686 185 82 377 646 206 499 414 632 630 438 836 604 475 475 598 160 305 257 593 274 214 378 681 457 83 155 835 622 16 132 384 712 387 620 452 862 297 164 719 366 838 805 290 595 467 313 64 282 576 63 845 93 795 16 868 184 136 436 543…
Output: NO

Example 2:

Input: 856 872 135 418 618 467 5 808 646 71 391 607 240 289 797 337 1 432 174 59 774 667 831 631 773 75 698 87 620 355 478 747 764 22 578 152 302 228 674 634 423 259 385 183 586 521 184 1 251 459 315 184 359 767 405 727 57 154 83 2 491 719 223 856 753 133 103 421 311 325 368 855 198 739 441 805 7 663 185 399 837 568 218 119 733 344 352 534 269 856 437 855 456 467 842 490 553 297 637 737 43 314 693 146 590 57 64 757 426 779 228 801 742 83 110 294 218 338 283 435 140 29 108 840 404 852 457 82 418 685 314 732 385 491 824 449 749 60 689 7 304 671 162 582 678 406 701 585 677 642 310 387 197 734 352 101 529 705 379 719 572 614 502 773 815 608 67 614 848 485 721 138 263 105 242 162 654 256 707 178 96 662 545 48 142 536 544 226 827 748 404 286 263 264 131 646 72 594 386 447 271 836 302 596 363 722 284 39…
Output: YES

Example 3:

Input: 911 344 319 284 183 166 776 655 476 500 678 358 80 647 592 346 898 30 634 115 11 666 778 648 744 807 418 382 357 673 462 622 424 802 298 344 482 868 856 296 770 73 452 32 265 371 286 414 861 865 755 706 540 891 399 790 46 580 466 806 697 27 333 445 606 446 763 205 268 503 277 10 733 309 25 807 114 789 747 85 100 759 202 509 802 125 386 531 292 27 772 189 842 80 287 317 546 764 132 560 13 742 866 593 267 780 605 890 235 799 334 405 33 582 601 822 522 442 779 372 619 545 3 152 730 178 873 863 762 81 82 313 635 668 404 567 382 102 147 461 226 122 22 583 377 701 751 158 236 463 44 732 217 764 138 675 135 155 13 873 818 464 250 565 208 458 908 643 197 91 467 751 743 634 309 603 317 256 447 254 50 911 510 325 819 295 517 328 334 800 307 813 645 809 473 665 26 501 667 547 261 766 362 791 786 456 …
Output: NO

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Saffron Circular Route - MEDIUM Coding Problem | CodeTikki