CT54226

The Circular Route Beneath Cinderline

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the railway depot of Cinderline. Amara spreads the routes records across the table and picks up a sharp pencil. 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 <= 1419; 0 <= m <= 1419.

Example 1:

Input: 861 1145 833 680 651 351 312 783 54 53 576 601 474 649 264 448 477 120 804 51 195 216 259 722 232 575 104 355 530 7 379 217 695 453 306 510 801 42 655 14 492 67 185 351 560 860 303 679 755 692 775 217 572 793 377 478 50 543 138 405 148 57 57 10 796 309 470 774 186 795 129 707 550 157 415 11 190 707 103 358 390 647 782 120 674 722 627 80 149 738 129 183 27 315 612 476 44 506 409 713 313 382 778 361 788 586 495 105 433 131 476 139 52 850 316 508 51 231 500 231 815 98 225 848 21 831 111 474 782 534 126 324 587 154 574 374 684 493 204 449 437 271 185 458 665 291 461 146 749 533 656 348 205 488 595 512 112 44 498 847 153 534 177 26 506 6 832 41 792 251 853 130 44 361 726 163 675 29 743 652 319 730 637 539 605 257 652 244 282 609 743 431 540 529 257 370 243 41 333 382 820 270 498 293 716 89 169 …
Output: YES

Example 2:

Input: 1296 271 906 578 609 569 1274 156 1201 1151 464 430 403 1122 1295 328 725 44 1092 223 47 189 1095 46 511 857 314 995 1149 490 281 439 346 667 1148 751 627 1178 1093 989 1028 640 676 1254 569 1205 246 134 402 393 644 968 508 248 593 1270 750 793 512 1190 1135 535 689 26 166 378 44 972 232 52 156 788 462 162 1151 530 86 294 1233 438 1159 536 530 84 1006 899 1142 1242 836 898 598 172 917 591 1142 627 814 1035 97 476 355 286 886 202 1231 167 891 693 526 753 387 157 1016 995 577 830 114 767 1085 598 573 106 669 350 394 1237 645 661 306 1110 508 924 258 492 1287 472 906 957 132 376 527 1016 860 185 772 253 839 158 294 163 1132 306 171 473 637 786 1033 538 963 230 780 1204 535 248 1216 657 902 866 852 855 706 510 102 658 473 571 985 739 978 38 610 11 430 682 144 1086 881 218 728 134 735 321 233 1…
Output: NO

Example 3:

Input: 1143 88 999 29 1024 790 305 321 368 836 661 1139 343 756 833 352 178 10 1113 489 1109 383 951 191 331 788 317 691 1082 10 596 487 1142 866 745 189 1065 755 181 133 638 693 149 18 232 907 1139 11 892 345 806 73 1063 267 866 703 355 1106 960 902 138 740 861 1059 1020 137 266 104 908 906 646 93 110 200 984 203 511 930 413 276 130 120 19 1028 851 65 162 1086 543 877 877 1051 451 99 773 1082 319 174 292 588 1048 328 1057 954 754 270 863 526 18 304 214 1087 638 565 575 968 717 1020 15 575 539 1027 748 443 1047 371 273 17 714 508 118 1046 138 457 655 65 1098 163 940 709 80 901 348 704 79 56 213 968 531 1134 988 333 518 494 610 650 788 365 689 139 533 143 529 511 923 99 177 397 730 16 75 265 265 821 662 551 323 1051
Output: NO

Constraints:

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

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