CT37425

The roads at Shimmerdeep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the opal reefs of Shimmerdeep pays by the answer, and Elowen intends to earn it. First: the full register of roads. 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 <= 1043; 0 <= m <= 1043.

Example 1:

Input: 928 549 770 389 761 487 124 646 895 378 518 920 863 700 814 746 642 501 877 641 532 104 64 69 583 762 826 124 872 846 595 14 669 355 524 590 439 303 387 693 848 744 215 171 418 513 118 520 540 668 684 541 287 341 6 392 577 688 650 737 757 202 327 400 796 278 315 596 200 119 324 669 65 411 570 368 500 483 922 8 229 506 788 716 344 674 602 343 469 643 720 186 86 851 708 170 219 263 41 58 188 486 371 756 585 241 643 268 858 402 73 325 304 89 681 85 365 39 124 926 446 681 7 390 414 374 662 346 350 678 83 772 670 804 472 604 260 89 568 364 592 92 165 906 207 525 529 408 894 331 486 862 653 328 292 623 642 604 722 819 714 278 812 482 927 647 91 319 649 325 105 293 196 501 44 484 15 880 567 875 541 853 680 671 296 3 870 501 198 824 268 629 716 601 140 491 266 504 476 97 698 213 880 54 45 137 302 …
Output: YES

Example 2:

Input: 647 611 301 179 590 259 106 635 323 362 153 560 51 283 150 463 313 11 233 408 226 487 235 122 79 369 260 245 304 402 439 468 522 345 139 260 19 199 324 171 147 250 389 260 614 131 510 182 208 305 39 106 480 231 36 114 73 412 36 636 106 379 37 18 188 463 319 589 27 566 76 64 447 361 216 531 161 487 325 6 573 605 103 179 348 626 121 421 162 365 210 539 490 161 2 581 395 145 517 284 15 539 640 492 397 543 152 80 440 15 430 613 212 382 419 512 645 524 478 430 250 481 80 559 413 148 466 185 479 166 7 13 196 177 131 159 391 486 523 472 583 377 214 286 434 174 391 332 370 162 202 477 339 641 582 587 42 552 300 481 488 159 472 495 531 460 172 406 74 128 490 102 433 318 110 249 607 169 526 565 37 249 64 647 7 262 631 299 192 414 406 532 233 43 265 420 121 436 565 472 74 637 169 475 571 128 252 529 …
Output: YES

Example 3:

Input: 733 657 500 633 62 490 623 494 252 662 223 112 515 696 162 487 440 338 53 267 339 567 560 552 33 525 400 72 334 60 502 635 708 601 226 637 114 240 410 330 593 403 544 402 392 573 412 229 239 472 548 182 307 137 380 680 55 727 339 511 111 267 351 622 101 96 704 194 464 499 463 539 700 70 25 604 584 614 55 176 201 280 654 467 156 293 378 671 406 334 406 261 481 128 223 729 496 155 497 702 304 146 483 11 593 24 26 536 306 321 115 654 623 380 630 205 583 169 460 647 392 321 428 174 524 339 184 699 92 539 708 480 451 69 405 519 201 682 318 421 518 190 88 648 628 21 248 40 725 470 165 413 215 623 182 218 250 120 565 668 496 123 578 333 697 82 731 247 660 338 658 360 648 18 373 720 700 43 407 464 249 536 698 170 638 135 401 475 565 117 76 617 644 565 511 603 122 164 599 455 270 235 429 131 655 18…
Output: YES

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The roads at Shimmerdeep - MEDIUM Coding Problem | CodeTikki