CT41636

The Fewest Hops of the Frosted corridors

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the ivy courts of Vineward pays by the answer, and Diya intends to earn it. First: the full register of corridors. 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 <= 2541; 0 <= m <= 5082.

Example 1:

Input: 503 2954 1 503 400 463 82 269 130 425 285 334 8 403 334 353 285 389 119 287 4 105 148 199 259 373 1 234 231 237 245 468 44 322 319 412 85 290 392 419 149 285 376 422 281 307 43 418 152 489 247 393 24 63 332 488 188 434 27 122 258 263 419 467 43 156 437 490 154 414 46 176 151 484 141 174 25 445 98 203 292 340 86 313 20 232 273 277 89 471 60 105 50 205 85 478 31 100 102 243 444 461 331 375 160 276 131 377 51 415 62 287 314 374 54 159 41 71 95 234 210 250 129 141 279 311 7 421 178 284 384 463 69 209 382 448 104 187 374 447 318 423 89 273 26 405 102 154 48 330 64 343 206 321 325 455 97 441 166 494 33 361 194 355 140 458 118 171 86 172 348 397 118 381 376 471 93 135 129 291 142 337 237 286 10 266 126 448 116 167 440 497 4 302 217 241 13 228 102 373 287 333 88 449 229 357 40 369 158 300 93 481 1…
Output: 4

Example 2:

Input: 261 2979 1 261 10 131 31 235 3 73 85 248 42 74 98 138 73 176 24 250 47 112 252 255 52 257 121 197 151 244 143 164 93 233 60 71 133 217 61 194 137 225 4 211 190 198 109 173 154 211 66 161 122 178 34 209 76 220 2 227 127 202 47 103 78 235 25 190 102 255 27 79 162 246 111 156 68 199 79 174 86 146 63 120 16 153 77 120 34 242 167 177 56 218 43 163 45 95 92 112 103 146 12 103 106 254 197 217 177 248 151 154 47 244 162 163 118 260 149 228 51 109 35 121 10 74 116 195 175 193 85 101 97 135 238 239 4 89 76 173 37 176 84 96 150 238 158 261 32 171 24 92 4 34 180 199 103 124 178 235 219 244 256 260 12 230 30 115 165 205 39 202 174 193 66 240 71 97 115 140 91 194 74 164 135 138 78 114 89 124 124 184 66 147 168 184 17 85 22 46 32 99 198 205 203 224 53 90 59 137 127 225 126 235 90 180 50 254 47 99 42 109 …
Output: 2

Example 3:

Input: 387 862 1 387 178 203 100 232 57 309 330 359 114 224 208 262 176 323 26 320 221 345 133 194 128 226 92 267 302 322 104 321 177 297 96 254 188 386 127 150 214 274 4 385 264 361 189 361 247 301 39 69 58 316 24 194 115 219 114 330 114 193 197 253 119 265 24 168 64 359 219 315 228 298 6 148 141 358 144 308 9 215 74 351 197 226 300 384 166 276 124 316 170 328 8 67 21 175 172 191 59 347 283 306 366 369 178 384 320 373 82 239 64 374 78 209 47 51 84 163 26 206 14 187 151 280 270 319 127 349 244 380 19 35 176 309 20 85 117 146 86 168 1 321 8 325 138 170 43 44 125 237 9 258 114 128 42 137 156 346 164 255 56 171 324 328 194 321 47 317 325 359 69 316 362 373 238 382 26 370 126 178 45 73 155 341 71 137 102 304 83 288 375 387 17 223 182 202 8 51 4 139 178 186 59 141 151 159 300 321 160 244 168 195 65 87…
Output: 3

Constraints:

1 <= n <= 2541; 0 <= m <= 5082.

Loading...
Test Cases:No test cases
No test cases available.
The Fewest Hops of the Frosted corridors - MEDIUM Coding Problem | CodeTikki