CT41433

The Circular Route of the Jasper corridors

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Felix runs the exchange at the gristmill of Rye Hollow. Today the books show a list of corridors, and the numbers must be worked out before sundown. 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 <= 1960; 0 <= m <= 1960.

Example 1:

Input: 728 1639 526 451 161 331 522 14 89 695 352 678 518 176 471 613 137 9 411 130 675 77 321 671 192 300 562 112 565 184 504 707 499 530 463 682 521 168 192 52 402 404 409 515 38 222 41 644 721 25 18 96 271 99 222 486 519 409 297 259 137 388 529 248 585 679 339 410 658 370 320 334 150 682 401 697 10 439 610 539 422 451 191 605 533 161 77 625 675 600 323 298 136 105 538 301 681 500 529 664 258 705 257 651 464 649 88 530 12 458 713 153 407 535 92 133 401 418 199 518 308 537 150 555 343 106 454 521 121 126 6 607 137 492 19 97 53 67 229 219 395 541 89 18 134 202 553 526 453 490 196 225 428 480 121 223 207 624 250 687 221 637 645 537 352 448 358 198 466 291 529 103 611 257 168 490 99 468 369 104 177 301 443 488 603 538 185 694 719 375 540 132 581 715 466 648 205 718 688 72 59 371 338 551 233 522 115…
Output: YES

Example 2:

Input: 964 1920 635 152 777 670 389 776 528 182 320 694 46 652 934 207 721 68 618 824 145 773 195 946 682 366 262 355 267 680 695 415 208 709 884 625 77 344 252 418 800 69 43 736 450 720 99 406 871 619 937 192 849 111 156 10 176 465 32 208 639 752 410 367 811 733 653 53 348 614 759 568 233 217 827 133 128 586 765 508 511 813 688 372 888 718 683 110 24 302 337 765 183 776 788 566 223 290 159 901 461 651 624 244 406 16 83 693 520 625 106 461 277 188 196 300 322 425 325 250 193 576 129 717 798 642 199 454 947 682 2 544 345 507 482 50 827 294 335 124 957 666 464 754 112 845 859 430 757 181 813 623 641 594 654 756 624 245 492 421 863 518 734 256 913 882 313 394 427 8 890 829 41 766 360 334 828 309 571 785 470 721 187 710 519 109 392 827 176 309 698 846 153 362 245 291 655 705 302 513 901 179 426 304 2…
Output: YES

Example 3:

Input: 1673 1254 1549 291 1393 522 1164 1264 463 1514 597 1110 661 369 378 64 575 682 598 727 813 589 1329 219 397 335 407 890 392 126 1125 142 46 502 513 1374 1407 308 501 92 580 1316 1310 678 423 1525 1237 414 1642 343 401 513 26 1146 1597 55 203 825 903 1339 1191 624 1331 1216 265 1426 1424 1644 769 627 1063 923 1201 156 7 1388 797 1510 1496 1275 1106 191 344 479 1056 346 1448 544 993 587 1590 1631 1092 76 1296 1271 1446 1523 1075 926 1583 1332 1239 1138 1002 144 30 123 301 753 1325 760 888 1616 340 569 1252 160 429 1428 840 488 751 1080 287 871 161 806 268 1239 358 1276 710 1068 1594 915 1186 447 835 1182 930 601 727 289 711 1638 747 402 1590 1396 825 1259 15 674 1470 314 469 1334 318 1586 579 1130 1351 1415 1203 6 436 942 1397 82 1308 503 235 340 266 898 1129 305 417 357 642 1382 762 414 395…
Output: YES

Constraints:

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

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