CT54250

The bridges at Lantern Tor

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Esha the auditor watches over the beacon hill of Lantern Tor's stores of bridges. A careful computation stands between order and chaos. 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 <= 2404; 0 <= m <= 2404.

Example 1:

Input: 944 237 778 408 261 201 557 292 792 262 881 695 34 487 693 476 213 944 81 80 735 659 35 901 850 71 494 645 601 251 425 666 663 75 902 436 942 629 374 483 242 441 37 624 731 353 657 727 466 263 116 607 603 634 891 136 169 913 478 904 905 942 791 733 294 667 672 428 47 324 291 548 799 881 808 635 866 458 355 447 527 128 290 393 773 516 367 391 539 524 310 609 583 9 196 574 673 235 369 878 180 296 822 253 921 430 27 257 759 557 374 746 284 56 765 142 764 40 565 501 189 264 72 736 819 275 80 169 687 734 724 267 849 682 144 740 305 672 33 150 491 56 655 450 627 119 422 594 599 18 731 925 627 564 218 431 181 940 891 532 103 653 751 13 339 942 569 754 92 879 872 217 111 546 515 125 236 691 454 287 478 205 64 15 896 433 832 828 265 349 204 402 831 584 186 689 830 737 289 115 856 239 807 309 413 50…
Output: NO

Example 2:

Input: 1937 1908 802 1594 1426 998 1623 1062 1055 1673 1184 232 495 987 31 916 151 1080 1642 1612 537 727 1128 671 564 1108 925 829 58 284 1619 1288 1341 1793 80 412 77 1651 1429 1654 1724 1475 751 1052 1884 1381 83 1544 546 155 1075 565 240 1801 504 1238 204 546 699 940 1130 632 861 1295 1318 609 1210 469 1809 609 156 1141 1868 873 1365 1747 1082 514 43 1264 1909 1603 1906 776 1270 613 395 1614 1693 749 1468 177 875 1104 1555 942 307 447 1455 1842 1680 1888 829 932 842 424 106 993 1686 599 235 73 79 543 674 929 841 337 874 1022 275 1622 1077 1611 587 1051 1644 1206 1309 55 1561 869 477 281 1194 1315 1573 333 1058 1004 386 273 1724 1773 1809 964 1136 339 1273 1746 1074 49 188 560 10 470 1894 1797 864 389 217 1561 1276 1557 9 1117 799 1407 1577 713 680 1769 1162 1769 276 1190 415 704 224 415 1200 …
Output: YES

Example 3:

Input: 992 662 959 95 97 418 196 361 283 579 921 422 565 678 157 688 989 619 478 372 368 744 278 876 914 249 796 63 887 62 364 414 480 936 170 675 615 735 549 86 779 861 155 65 964 799 430 466 245 468 43 188 799 715 976 610 284 7 581 442 463 887 570 742 674 642 71 591 576 654 514 822 858 349 349 24 184 388 950 838 832 11 89 378 429 954 636 918 323 6 919 792 662 198 788 646 322 177 398 179 496 383 81 67 756 359 352 235 390 101 596 432 591 260 802 560 241 300 167 882 410 354 112 41 562 33 579 85 885 95 203 450 49 719 350 8 837 113 923 897 830 524 75 367 925 952 198 660 349 6 403 367 828 15 942 359 572 115 387 778 818 72 897 216 522 785 350 847 651 730 266 513 964 250 829 408 871 490 625 419 346 818 233 564 434 892 133 99 872 121 469 265 287 617 53 252 328 541 194 182 48 548 676 692 738 57 55 676 61…
Output: NO

Constraints:

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

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