CT34664

Rowena's corridors Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the shale slopes of Greystone. Rowena spreads the corridors 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 <= 1062; 0 <= m <= 2124.

Example 1:

Input: 405 1535 1 405 85 199 191 204 277 327 67 119 68 349 248 279 112 297 164 318 297 362 80 240 67 373 27 382 174 392 78 258 126 348 131 386 94 372 40 351 17 321 138 394 46 134 267 402 224 398 28 332 125 128 41 156 67 188 149 207 50 96 69 191 42 49 37 227 128 246 32 289 94 364 257 397 110 169 69 289 10 393 217 293 385 387 108 399 108 185 280 371 3 90 97 126 113 366 77 243 69 391 12 397 80 222 222 328 140 278 250 251 210 325 99 309 293 374 105 145 23 192 132 250 50 204 103 275 75 203 65 292 7 392 206 212 337 368 71 245 123 241 133 143 90 379 52 332 185 222 12 243 193 282 192 321 281 327 141 307 13 189 12 89 42 193 109 210 174 377 5 280 88 167 213 377 128 326 152 333 171 278 83 225 164 374 106 296 11 150 255 333 135 145 200 307 11 288 4 405 107 237 278 346 123 169 58 212 52 81 96 127 85 234 34 13…
Output: 3

Example 2:

Input: 278 742 1 278 15 48 104 142 43 69 179 250 240 278 240 277 2 17 25 229 16 26 50 273 79 198 15 198 103 268 107 114 55 133 117 272 3 190 58 87 1 161 107 168 38 106 95 196 108 251 209 263 15 34 99 273 159 212 213 273 133 158 36 81 38 223 8 204 117 173 184 268 145 274 122 271 77 237 84 221 163 257 83 258 36 271 244 278 110 113 115 252 177 241 9 212 134 239 51 158 74 259 223 234 79 84 131 255 135 264 7 102 149 238 94 252 22 86 33 210 117 126 158 179 71 98 56 105 35 196 23 216 18 140 32 215 56 76 86 221 122 141 135 220 131 204 191 228 9 132 109 159 210 237 33 254 92 175 139 232 115 244 192 256 95 229 157 163 102 149 29 42 17 106 151 222 21 187 68 273 30 49 123 167 41 128 165 247 88 108 130 168 147 169 35 239 71 271 25 219 89 153 152 234 224 231 218 222 71 167 113 154 146 260 24 51 79 144 156 205 …
Output: 4

Example 3:

Input: 1047 1682 1 1047 198 261 80 559 333 881 642 1000 286 375 715 996 581 851 250 785 230 954 806 1038 727 1031 32 747 653 773 88 406 142 155 196 484 433 467 254 623 4 210 295 457 326 717 940 974 290 865 227 623 826 1020 83 958 70 772 293 549 169 423 199 334 610 640 203 1021 832 864 13 396 324 1026 423 635 32 974 439 592 729 747 99 481 758 990 103 482 38 623 184 768 36 803 535 877 21 520 771 830 408 939 306 686 16 1013 254 369 157 417 311 876 371 1003 321 468 336 942 148 400 378 513 124 289 361 914 82 393 18 935 73 111 126 681 475 582 9 72 38 589 546 845 862 872 404 953 138 325 524 627 221 450 503 762 2 492 12 111 30 561 369 483 616 719 30 988 241 394 812 854 604 678 476 1043 471 486 16 299 535 655 271 783 678 875 910 1011 608 800 363 623 128 963 47 999 282 761 816 873 375 413 101 594 617 931 6…
Output: 7

Constraints:

1 <= n <= 1062; 0 <= m <= 2124.

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