CT44743

The Circular Route of the Beryl corridors

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the pearl fisheries of Nacre Bay with crates of corridors, and Indu the accountant must account for every last one. 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 <= 1414; 0 <= m <= 1414.

Example 1:

Input: 731 1213 682 182 179 676 114 702 645 1 472 371 19 342 190 248 689 573 48 469 175 98 182 330 471 83 136 718 233 584 189 451 602 319 550 18 341 631 625 619 543 654 365 464 146 168 631 721 424 363 514 134 621 693 167 319 436 472 624 554 551 502 672 505 172 322 426 109 372 496 424 152 483 164 592 155 337 441 541 452 548 607 697 711 23 76 522 481 104 526 719 224 584 308 275 27 290 283 275 40 600 35 456 391 167 261 251 217 279 330 357 550 81 207 643 233 676 643 268 61 555 232 627 538 440 700 527 608 78 285 244 542 91 214 521 147 100 182 518 565 671 654 523 612 154 269 256 101 143 565 171 2 401 507 266 173 540 563 642 66 302 158 640 140 212 538 461 468 32 312 388 78 164 30 628 129 679 606 547 469 414 126 227 79 690 726 340 616 576 56 630 417 620 608 80 629 92 112 312 223 514 71 523 115 202 189 33…
Output: YES

Example 2:

Input: 1342 915 802 1227 1064 1050 700 1041 907 390 577 1174 121 875 434 437 874 965 809 436 417 121 1246 551 903 848 768 574 1157 1089 913 475 798 1167 600 925 374 55 1176 1030 1278 839 1219 247 517 137 1137 309 830 1044 1073 1061 1073 310 254 95 893 824 360 391 1327 12 899 730 235 560 424 88 598 703 296 349 1071 1098 762 1316 1334 915 170 222 931 456 665 208 1066 85 236 856 1254 585 264 281 510 639 118 948 836 144 782 595 411 242 493 1166 1126 677 614 1334 1112 686 911 723 193 1128 715 1221 665 530 393 909 514 662 693 463 1319 1064 1138 115 1079 1225 663 1311 60 778 981 760 670 151 498 1175 101 12 1335 716 1324 191 845 1039 174 354 1301 439 515 84 698 40 1249 163 568 1034 1273 380 345 1259 102 167 112 731 47 502 421 160 709 284 840 623 1222 19 602 616 16 969 398 809 653 1020 71 1108 1016 1151 1…
Output: NO

Example 3:

Input: 955 180 759 131 749 743 831 179 28 471 567 843 694 904 3 94 626 105 553 921 359 585 19 23 653 91 87 527 475 689 261 224 823 397 824 534 284 627 176 497 954 776 488 304 146 736 203 148 54 666 670 144 65 376 887 708 516 841 932 882 812 548 223 47 434 462 405 210 54 458 625 823 905 62 165 748 102 189 408 346 418 216 726 517 623 895 485 549 400 918 317 650 654 166 891 828 259 215 389 851 647 462 473 451 236 70 299 512 659 608 251 870 617 744 9 494 789 25 259 902 805 242 655 291 299 241 337 371 223 431 156 185 99 211 858 874 736 153 689 414 822 5 479 594 917 408 580 43 735 502 884 920 247 287 760 706 224 344 570 736 146 621 29 239 868 243 584 526 638 87 376 336 864 323 66 361 534 21 407 166 131 473 559 815 780 470 353 940 554 406 767 319 295 32 136 442 938 406 844 275 783 604 485 74 201 679 943…
Output: NO

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Circular Route of the Beryl corridors - MEDIUM Coding Problem | CodeTikki