CT37194

The Pale Fewest Hops

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the pearl fisheries of Nacre Bay pays by the answer, and Kabir intends to earn it. First: the full register of routes. Task: Print the minimum number of edges on a path from s to t, or -1. Input format: First line: n m s t. Next m lines: u v. Output format: Print the BFS distance or -1. Constraints: 1 <= n <= 3110; 0 <= m <= 6220.

Example 1:

Input: 858 2170 1 858 334 835 511 609 12 601 369 844 262 529 137 536 410 423 653 802 254 848 155 795 279 305 171 672 379 842 431 834 355 669 361 832 24 341 24 328 355 436 196 378 32 789 477 568 181 384 285 757 597 827 593 655 21 467 397 701 14 178 425 724 248 283 171 486 243 464 575 607 586 818 200 707 312 474 105 207 346 551 480 500 230 785 164 812 72 240 387 820 42 314 189 831 254 740 338 659 324 479 333 731 137 455 347 578 572 675 701 847 28 636 398 542 7 242 474 698 213 769 121 156 753 826 273 645 458 575 248 836 140 807 602 729 519 660 187 857 477 675 419 773 45 401 215 444 491 565 34 663 584 723 396 853 115 521 144 783 514 636 14 323 700 775 24 758 718 786 40 97 532 639 519 583 173 437 675 731 734 784 151 351 177 826 131 573 340 719 425 760 175 643 281 611 591 810 338 819 8 75 452 716 21 51…
Output: 5

Example 2:

Input: 3007 3006 1 3007 836 1767 610 2744 144 1116 885 1068 1338 2599 1181 1359 162 2420 1510 1519 852 1199 133 228 1794 2442 2509 2760 1313 1989 662 2382 1259 1462 1661 2148 642 1360 244 2807 865 2353 132 2550 1125 2089 149 215 1937 2833 833 1223 430 1934 2492 2974 302 2660 1683 1937 585 2499 646 1441 2654 2920 88 2813 1460 1780 522 2375 548 1949 1441 2439 1568 2256 256 1984 1748 2170 1218 2039 750 2839 1270 2138 1968 2708 756 2410 132 2353 2263 2495 1199 2666 2100 2189 1065 1638 146 1472 368 2003 920 1260 1279 2428 1012 1403 6 571 304 2139 365 2539 117 1793 596 2353 422 968 1751 2977 412 512 1803 2658 37 2351 563 2163 1087 1736 1004 2536 231 1320 1476 2934 690 2320 1521 1774 354 2281 1280 2144 771 1057 39 2292 764 2977 410 2535 1355 2620 1350 1523 1529 2747 485 2052 62 2756 1490 1958 257 2911 6…
Output: 11

Example 3:

Input: 2298 2297 1 2298 375 1812 18 1553 638 1312 592 2049 881 1809 412 896 425 1755 1871 1942 437 1905 1980 2046 375 431 623 718 1728 2260 159 1314 939 985 1891 2271 1420 2000 773 1780 844 1146 1187 1807 103 916 1262 1933 1314 2269 1330 2082 1572 2123 503 1792 465 2136 675 1192 1786 2157 142 759 280 827 1366 1989 1295 1766 2107 2210 387 1471 968 1539 112 2059 770 1178 1553 2257 121 1866 1123 1665 554 1891 464 1607 483 1655 423 504 1472 1673 603 1114 519 1965 209 1501 1032 2121 1400 1670 1113 1729 785 1604 414 1199 1561 1971 1920 2030 692 1599 1632 1660 1015 1160 3 215 687 2073 520 974 479 575 1311 1508 1337 1758 1837 2167 551 2177 1204 2093 1206 1759 428 838 715 2063 973 2120 136 1236 768 2158 1758 2064 158 832 803 1050 212 1569 1390 1429 1872 2272 767 1109 342 2012 561 1718 72 1852 685 1694 315…
Output: 7

Constraints:

1 <= n <= 3110; 0 <= m <= 6220.

Loading...
Test Cases:No test cases
No test cases available.
The Pale Fewest Hops - MEDIUM Coding Problem | CodeTikki