CT44325

Grey's corridors Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The customs officer Grey has been asked to verify the safety inspections. On the desk lies a long table of corridors readings. 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 <= 2013; 0 <= m <= 4026.

Example 1:

Input: 1837 2788 1 1837 1124 1784 116 270 1269 1371 842 1739 84 617 79 1348 267 984 265 1566 476 489 779 1419 902 950 493 812 1436 1600 891 1833 166 1816 98 794 345 1486 1097 1321 1105 1518 1214 1454 143 265 1268 1688 1250 1806 666 1291 200 244 264 1095 1436 1519 175 1706 1018 1121 22 854 339 1386 395 1051 1714 1826 628 1370 728 1764 927 1298 732 1233 682 1790 877 902 1235 1444 315 1001 106 1538 229 1835 268 429 985 1318 32 278 879 1640 480 579 586 780 195 260 1342 1721 5 612 797 1815 355 1625 426 1084 759 1453 363 1386 747 884 274 769 1407 1510 730 1208 104 1684 1002 1603 718 1082 306 1308 98 1486 677 1081 1414 1766 604 1643 400 1522 355 1247 261 1686 223 698 181 985 962 1587 1512 1636 468 1307 1482 1799 1206 1701 550 848 55 598 1120 1660 1310 1778 408 688 167 1148 478 1104 328 1019 1477 1831 12…
Output: 5

Example 2:

Input: 1890 1889 1 1890 133 540 1539 1698 534 1423 633 705 582 1061 813 1154 501 1326 41 1571 392 1610 560 632 82 1722 692 1281 609 1841 255 1054 1314 1699 1528 1738 383 1825 798 1185 839 1146 113 1883 642 1179 130 133 1296 1524 313 1194 52 1213 309 1347 129 308 1311 1765 843 1272 680 1630 403 1754 1301 1397 1316 1854 127 1454 949 1591 821 1281 577 997 448 1190 336 1886 732 1767 1097 1610 1002 1450 18 1465 769 1440 758 1668 376 599 78 836 1183 1440 131 1595 992 1236 131 1587 382 1296 235 372 728 787 194 1227 485 866 911 984 656 1435 1440 1795 863 1325 450 1514 787 1414 633 1598 83 713 883 1886 891 1566 750 1013 749 1872 1062 1850 282 1591 301 545 565 1366 75 540 432 1809 305 499 573 1531 797 1067 691 961 127 354 132 1603 268 1474 732 1398 152 1655 1219 1571 630 834 940 1409 799 1272 696 1722 67 6…
Output: 15

Example 3:

Input: 1088 1757 1 1088 208 778 245 1026 561 793 825 873 812 977 70 1017 627 1011 33 741 586 721 192 730 643 1035 162 837 270 945 1 639 174 611 331 876 338 506 907 1042 206 512 18 427 75 568 352 699 279 1028 638 686 400 794 454 511 799 831 10 892 188 489 425 623 16 738 37 366 86 734 835 1072 66 949 38 497 338 495 43 730 104 743 92 1088 262 841 269 998 745 903 139 444 538 791 26 357 261 521 24 967 147 897 82 627 424 803 56 1083 306 625 164 207 321 630 136 723 220 805 636 796 481 1086 681 794 621 857 703 939 176 556 32 908 423 783 155 531 629 1050 437 527 644 967 376 517 71 587 280 1020 458 675 241 300 153 892 460 780 31 701 277 811 499 638 104 442 546 835 232 380 750 920 607 647 317 877 559 612 251 408 313 596 54 744 348 588 383 654 66 180 173 385 197 437 747 816 487 758 198 758 339 386 411 770 25…
Output: 7

Constraints:

1 <= n <= 2013; 0 <= m <= 4026.

Loading...
Test Cases:No test cases
No test cases available.
Grey's corridors Reckoning - MEDIUM Coding Problem | CodeTikki