CT56419

Last routes of Kael

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Kael the tallyman watches over the ember mines of Cindercrag's stores of routes. A careful computation stands between order and chaos. 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 <= 2311; 0 <= m <= 4622.

Example 1:

Input: 2047 3762 1 2047 1527 1845 582 898 1996 2005 1175 1275 1006 1789 308 1057 179 425 343 806 424 819 1327 1836 268 1431 1537 1542 82 1337 403 1728 969 1840 1603 1647 519 1671 4 292 19 824 418 1706 146 1059 456 816 937 1357 612 1006 671 2020 35 1552 695 1703 32 1043 1010 1778 58 943 1899 1954 159 230 752 1422 124 1555 191 313 395 718 1898 1909 365 1440 646 1800 628 1764 82 908 1037 1389 1324 1807 943 1225 1212 1615 1473 2014 1109 1155 400 1670 26 1732 564 690 435 1602 162 490 707 1585 396 1080 35 1340 1015 1622 1069 1161 1411 1455 562 1494 1592 1620 902 1388 63 937 114 732 159 690 902 1477 644 1804 1394 1668 1420 1907 346 1905 322 1038 168 1920 84 1519 226 1765 594 704 649 1691 132 1371 1404 1660 130 1330 670 1890 149 1919 522 1305 645 1701 1210 1312 891 1031 314 554 512 824 39 831 108 597 747…
Output: 5

Example 2:

Input: 851 852 1 851 586 743 682 699 111 201 129 726 429 740 266 677 194 737 490 745 140 192 128 190 401 634 73 807 199 700 497 602 659 704 631 809 44 799 78 683 27 651 518 662 484 597 364 397 338 359 279 561 253 418 197 400 160 335 246 836 356 732 621 653 269 769 57 708 813 846 401 469 384 767 99 333 28 578 310 805 375 571 392 777 346 370 164 593 502 783 260 422 712 761 8 9 739 742 247 374 63 319 525 529 511 618 339 494 442 759 5 746 145 323 599 842 368 487 401 752 280 814 158 823 128 532 323 576 231 234 168 565 2 189 135 526 174 598 35 804 350 544 43 847 250 646 268 538 145 163 75 217 207 843 455 699 23 602 434 702 279 422 471 722 302 351 24 849 394 749 154 614 143 492 26 536 115 656 321 403 61 253 51 612 358 822 19 457 122 244 224 501 68 431 19 766 183 421 150 705 55 70 52 796 200 669 60 678 4…
Output: 13

Example 3:

Input: 1299 1298 1 1299 1145 1195 502 1168 1029 1153 233 236 305 616 545 1149 308 459 1091 1167 95 456 109 504 325 900 240 328 106 160 1 602 371 735 569 1200 687 1198 344 691 742 827 88 181 360 591 173 922 5 55 409 1227 235 1158 771 1070 14 914 118 993 544 1022 139 1279 946 1215 12 1295 431 568 468 989 556 1052 44 59 430 738 204 1170 463 865 797 1116 900 948 78 716 115 527 840 1209 228 683 775 893 128 778 1045 1186 162 546 131 729 271 301 194 1047 167 272 299 750 1114 1174 252 632 280 865 869 1046 359 916 98 192 960 1149 367 900 238 473 83 319 57 1101 270 1239 69 1124 354 678 1089 1253 753 881 950 1181 272 849 174 1237 190 352 785 896 802 1157 654 1272 339 867 527 995 423 693 459 620 141 1215 133 1256 905 1071 886 1271 592 721 632 780 1120 1254 35 473 51 331 1109 1130 471 967 60 293 788 1258 149 …
Output: 7

Constraints:

1 <= n <= 2311; 0 <= m <= 4622.

Loading...
Test Cases:No test cases
No test cases available.
Last routes of Kael - MEDIUM Coding Problem | CodeTikki