CT52667

Grey's tunnels Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the steppe camp of Horselord Plains. Grey spreads the tunnels records across the table and picks up a sharp pencil. 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 <= 2768; 0 <= m <= 5536.

Example 1:

Input: 176 2007 1 176 25 87 84 102 5 21 43 117 43 64 30 101 8 76 13 49 9 166 81 103 25 73 79 103 79 130 38 144 117 135 28 141 7 69 145 162 23 68 26 51 42 122 82 97 118 125 96 133 88 100 18 175 45 121 117 124 14 165 125 164 109 135 20 36 14 134 49 100 34 106 86 140 111 145 61 173 14 61 100 176 35 56 5 44 82 109 35 41 10 12 24 92 21 103 21 42 9 172 62 153 2 96 41 106 4 132 53 170 132 176 27 99 139 150 13 70 29 140 33 174 90 137 63 125 62 133 32 161 34 46 11 169 130 168 54 123 101 165 71 124 17 29 11 74 157 171 68 142 17 150 13 158 85 120 110 166 167 172 85 97 78 163 71 81 70 117 97 171 17 52 23 164 1 132 52 64 94 104 8 10 95 122 24 33 160 165 34 74 58 147 72 129 1 161 61 128 25 47 1 104 14 58 35 133 6 122 101 167 37 84 68 113 42 166 63 108 23 146 103 109 37 47 91 114 74 119 6 40 28 37 70 125 89 93 …
Output: 2

Example 2:

Input: 363 2126 1 363 95 242 185 306 183 330 116 225 69 245 231 356 148 209 72 101 260 344 157 321 162 332 171 192 22 46 296 342 194 300 15 303 81 359 26 181 269 336 155 199 210 255 144 188 36 316 93 346 139 146 31 124 42 253 57 272 128 289 67 73 212 327 93 209 20 342 13 295 221 301 149 323 55 118 1 141 78 121 70 363 137 283 245 308 13 249 134 213 82 114 139 153 82 134 227 290 17 200 105 314 72 119 160 322 83 112 3 360 128 246 222 360 200 205 163 221 21 321 54 230 300 333 11 86 176 192 35 157 76 261 298 348 128 170 282 362 166 251 47 172 196 209 15 361 20 231 13 317 116 178 30 83 197 310 181 303 136 145 28 87 229 271 169 303 15 314 89 145 118 139 58 205 14 291 254 292 135 360 188 357 121 243 98 358 57 251 72 279 241 356 271 358 43 249 35 223 181 204 22 220 10 263 195 213 301 338 103 251 138 272 7…
Output: 2

Example 3:

Input: 1849 4468 1 1849 1361 1412 49 978 22 1374 546 1335 861 1162 377 1038 174 606 477 490 411 652 1455 1767 367 1464 345 737 510 565 504 947 255 1195 392 896 461 1643 1620 1664 1251 1816 1473 1702 273 1119 1704 1715 1031 1492 266 386 43 1265 147 1212 1382 1712 1119 1570 671 1653 832 1208 1014 1552 27 423 90 303 50 1440 86 1480 114 327 846 1406 141 1456 143 1197 1359 1382 1386 1572 434 971 1021 1096 641 1328 458 917 650 1605 432 1514 291 697 626 1105 223 280 650 1736 1024 1245 339 1779 136 773 862 1775 1103 1687 525 615 102 1046 1170 1421 863 919 264 1387 807 1573 1137 1818 334 981 527 1709 1590 1805 70 1755 1478 1819 95 1114 39 1648 621 1334 1652 1699 801 1221 875 1621 985 1463 688 1275 778 907 293 1807 166 1443 422 1132 1151 1529 135 1357 1152 1198 81 817 709 1690 885 1432 908 1215 849 1462 64…
Output: 7

Constraints:

1 <= n <= 2768; 0 <= m <= 5536.

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