CT55423

Xara's tunnels Fewest Hops

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the singing sands of Echo Dunes, Xara studies rows of tunnels entries. One clean number will settle the guild's oldest argument. 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 <= 1657; 0 <= m <= 3314.

Example 1:

Input: 226 1668 1 226 34 95 103 109 106 214 84 176 32 51 13 30 19 27 22 192 20 79 21 146 57 196 109 164 129 208 24 117 22 43 11 171 112 224 104 160 200 226 20 109 80 84 78 165 113 149 40 179 31 58 86 186 24 37 27 75 164 226 40 198 155 169 14 214 5 163 52 175 154 168 26 129 75 197 24 166 89 215 138 202 149 198 152 155 158 190 148 197 59 75 20 53 137 168 33 87 33 36 16 67 24 157 81 118 134 144 140 184 17 47 114 164 109 143 77 140 55 57 107 201 36 126 1 141 142 148 119 215 31 206 141 207 21 42 13 149 164 222 175 183 126 146 45 71 152 161 150 179 199 210 29 89 119 210 43 94 37 136 137 219 89 141 91 225 37 167 27 226 65 91 23 151 195 207 84 216 87 160 63 203 159 161 84 115 62 189 188 206 10 114 29 125 19 91 67 216 53 210 52 81 49 176 79 121 149 209 148 198 70 79 40 92 47 224 19 57 97 137 33 79 165 202…
Output: 2

Example 2:

Input: 1190 1189 1 1190 621 769 282 978 22 598 119 996 114 608 447 833 371 936 926 994 64 616 106 516 637 718 141 911 86 806 72 872 543 1124 104 488 409 1114 235 765 299 1077 401 1031 863 977 805 1183 619 984 899 1112 17 1139 250 1101 709 1055 603 649 503 636 810 1050 7 359 321 1041 418 1071 463 888 277 525 942 1150 22 1003 960 1119 21 525 191 313 164 290 564 990 1047 1189 530 1128 386 793 334 848 575 1038 435 875 804 898 257 276 255 617 596 1085 587 918 280 394 313 1035 147 1029 477 627 133 1009 955 960 125 137 628 727 1086 1092 624 1167 160 805 138 804 546 983 407 552 147 305 186 720 587 1039 161 823 712 1134 120 160 993 1142 787 1166 195 990 267 463 214 1142 151 1134 658 1072 166 849 32 130 553 1108 287 541 6 1183 405 969 104 1028 650 948 365 654 572 839 303 458 65 106 228 328 322 1001 504 862…
Output: 10

Example 3:

Input: 1358 1357 1 1358 179 810 98 1131 612 1292 841 1068 140 809 228 671 952 1033 497 645 1294 1323 573 1268 71 509 299 1283 254 683 249 1345 348 846 818 1038 52 756 732 1269 484 655 145 208 1116 1182 300 558 372 615 683 1091 274 999 417 585 519 716 616 962 747 930 513 713 343 358 1083 1116 724 1292 244 1272 114 732 320 589 62 464 886 1195 558 589 322 719 113 515 451 1192 1075 1135 629 1241 524 806 139 577 91 905 56 762 327 418 155 345 737 985 192 508 579 1199 291 376 369 739 788 1256 597 1061 791 915 683 1117 139 154 253 267 514 878 277 902 47 1296 334 555 338 535 630 899 836 1155 996 1081 222 518 136 557 718 1079 11 1315 602 1170 664 1207 760 839 421 1154 790 1056 577 723 475 1162 939 1219 509 1232 1237 1285 594 735 266 1120 5 357 250 320 755 1347 574 884 761 890 936 1104 851 1285 599 925 70 6…
Output: 11

Constraints:

1 <= n <= 1657; 0 <= m <= 3314.

Loading...
Test Cases:No test cases
No test cases available.
Xara's tunnels Fewest Hops - MEDIUM Coding Problem | CodeTikki