CT33853

Brevin's Hidden routes

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the tundra station of Whitesnow; Brevin weighs the day's routes manifests and starts the calculations. 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 <= 1742; 0 <= m <= 3484.

Example 1:

Input: 1503 2715 1 1503 623 1457 569 1106 201 314 878 993 258 548 26 644 306 1213 1128 1189 45 771 767 1245 1172 1335 687 1030 417 1251 416 909 309 970 526 836 544 1310 138 583 839 1287 602 723 34 432 1335 1398 524 956 570 1205 206 500 675 1360 91 1051 699 1285 1108 1365 487 1261 332 562 538 1033 529 1342 615 832 228 1154 205 328 393 1324 692 1331 82 584 1046 1128 92 1022 477 558 434 1030 305 559 413 855 729 1111 285 434 1285 1500 668 1124 755 866 370 1502 103 1483 13 45 885 1380 556 677 708 1485 648 670 264 1035 813 1261 778 891 157 1146 55 333 83 531 1241 1336 630 1265 844 1370 313 1347 981 1324 127 366 294 555 811 1427 192 893 1263 1434 1209 1387 1051 1370 842 1211 34 119 53 495 682 1321 705 952 1129 1478 324 469 534 741 144 1048 680 1127 442 932 826 1232 598 1140 481 902 519 781 1051 1410 808…
Output: 7

Example 2:

Input: 153 1638 1 153 29 109 48 72 21 36 29 31 19 36 4 133 57 63 104 151 50 76 48 109 47 143 26 135 7 105 37 62 24 139 50 64 8 117 29 143 88 110 63 128 114 126 8 101 16 129 31 153 68 136 9 26 104 119 9 49 6 26 14 74 2 39 10 94 43 67 64 101 5 85 74 114 72 88 23 105 113 120 60 128 105 122 40 119 103 105 65 105 20 134 64 121 117 134 64 122 54 131 52 74 40 138 92 144 77 95 62 132 100 117 89 129 49 130 65 114 123 152 61 113 19 84 25 102 101 144 61 148 30 115 2 10 1 36 87 88 13 141 15 132 22 109 27 106 46 62 20 49 23 32 8 64 2 141 101 130 13 66 12 48 105 108 22 50 87 139 22 62 56 131 75 112 131 138 87 109 73 106 115 151 8 93 37 57 60 108 105 117 33 143 20 72 45 97 47 136 48 80 1 140 28 148 39 45 77 105 88 124 49 110 64 142 31 92 38 74 19 103 97 101 61 98 58 93 95 107 147 149 46 122 56 58 138 151 23 148…
Output: 2

Example 3:

Input: 1203 1408 1 1203 204 624 849 1048 170 424 308 690 539 723 463 1165 378 792 580 836 66 1056 624 921 326 637 386 654 189 619 43 1099 758 1101 472 1174 68 914 83 543 253 992 896 1107 398 1134 175 620 9 398 465 593 529 1049 218 1039 427 876 380 517 697 942 854 887 75 573 20 1112 706 778 1034 1172 246 1009 527 533 250 844 43 1105 427 929 640 1175 609 918 287 431 122 850 30 492 178 291 670 782 613 1009 5 181 77 794 282 1065 672 1137 595 1017 455 1016 885 1071 11 273 89 398 30 656 35 1129 292 1158 429 544 57 894 1024 1027 305 460 320 576 349 970 93 143 63 536 671 923 272 1160 58 942 686 888 219 444 42 1070 143 604 553 890 181 326 58 794 490 1050 485 1135 452 727 233 312 454 1128 136 347 220 485 253 1014 501 732 95 697 736 1177 653 775 63 846 150 1082 185 414 389 1104 308 1035 166 388 255 829 228 …
Output: 9

Constraints:

1 <= n <= 1742; 0 <= m <= 3484.

Loading...
Test Cases:No test cases
No test cases available.
Brevin's Hidden routes - MEDIUM Coding Problem | CodeTikki