CT34908

Lara's corridors Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the clockwork quarter of Gearford as Lara unrolls the day's manifest of corridors. The tally will decide the next shipment. 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 <= 1278; 0 <= m <= 2556.

Example 1:

Input: 520 1480 1 520 113 246 123 519 31 182 380 507 61 211 74 440 314 380 158 506 183 364 24 510 368 434 424 499 102 481 63 393 32 488 169 245 203 391 208 391 342 458 376 441 22 276 299 305 40 368 42 55 242 361 73 144 52 245 227 244 79 360 89 212 230 474 412 431 342 487 370 477 46 212 241 449 295 451 119 515 37 126 120 456 373 475 121 280 42 317 112 148 43 418 120 373 160 419 46 350 281 343 461 496 359 485 24 132 310 429 23 192 246 255 212 274 201 398 161 442 35 290 3 465 44 211 182 351 194 290 312 350 252 342 334 374 30 489 284 421 414 471 6 65 478 504 170 509 123 406 92 170 344 477 71 258 198 510 342 429 97 344 160 353 85 168 65 513 151 248 145 242 1 179 114 284 83 262 99 430 12 277 406 416 169 409 251 329 399 406 178 229 77 307 60 368 212 477 130 152 92 368 7 213 423 495 216 234 100 124 43 33…
Output: 4

Example 2:

Input: 618 1811 1 618 485 556 106 560 174 351 595 600 288 549 103 172 149 400 457 575 120 485 252 257 254 460 20 110 121 591 398 424 62 222 23 178 366 584 145 382 77 531 246 474 372 576 310 534 76 440 348 360 306 501 52 611 235 320 96 524 129 205 62 595 35 144 256 414 251 478 36 568 271 563 27 585 336 547 552 572 246 592 60 367 376 508 320 593 223 240 44 180 239 401 76 557 249 583 128 400 152 285 546 595 80 235 111 196 178 601 305 529 495 579 120 146 99 333 45 462 113 342 150 435 69 135 10 197 97 415 208 239 462 507 241 541 259 563 331 348 55 199 158 477 374 547 90 340 267 591 424 495 166 551 193 515 404 613 240 547 324 406 93 480 142 558 464 552 79 465 27 91 311 319 238 283 214 301 438 594 326 486 342 372 217 353 79 110 218 545 416 423 18 538 121 340 303 424 139 512 54 502 152 499 73 524 136 199…
Output: 3

Example 3:

Input: 1150 1149 1 1150 71 524 286 1085 274 880 638 878 659 1061 25 656 315 598 366 961 16 723 34 475 40 541 844 983 615 977 618 999 549 902 570 695 636 1090 65 388 942 1107 211 798 303 662 154 758 163 557 224 254 869 886 126 537 171 205 51 261 548 1112 289 702 296 1052 140 226 153 630 19 659 302 1060 443 801 412 1140 381 1070 214 1067 8 453 556 845 396 862 6 1084 50 1017 24 1081 577 1055 533 970 624 736 122 998 73 851 141 189 108 1078 387 591 484 994 853 1041 41 431 161 790 204 509 329 1116 72 472 699 827 689 1017 616 821 1031 1037 238 405 594 900 163 547 128 1134 632 882 331 659 724 856 72 315 994 1035 792 1041 288 739 333 460 416 924 171 1079 52 1082 613 1069 606 917 246 286 1065 1073 979 1118 899 902 196 704 34 954 536 794 537 629 534 561 431 993 465 522 71 255 11 217 630 722 157 297 106 822 …
Output: 14

Constraints:

1 <= n <= 1278; 0 <= m <= 2556.

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