CT32311

Bishop's Ledger of routes

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the lily shoals of Padmore, someone must prove the quality of the harvest. This year the task falls to Bishop, armed only with the routes register. 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 <= 1349; 0 <= m <= 2698.

Example 1:

Input: 300 797 1 300 78 161 96 164 75 157 10 190 17 282 50 232 200 268 78 140 104 118 82 96 89 243 120 135 75 102 97 196 161 245 27 70 182 214 150 264 48 111 85 109 157 243 183 286 145 294 200 265 12 128 146 271 102 229 92 145 95 280 232 252 120 210 129 207 127 273 18 221 39 219 88 127 5 184 224 261 1 80 20 44 70 208 28 283 229 279 95 221 126 137 200 234 44 115 110 154 2 5 148 180 203 255 47 200 41 146 222 268 193 271 160 233 218 250 24 165 141 225 54 195 158 241 150 203 25 160 212 285 13 191 47 159 209 212 53 203 130 219 74 260 67 220 24 259 180 275 261 290 122 125 127 158 12 114 205 262 3 253 140 149 4 272 51 184 5 203 119 171 163 232 37 72 70 199 184 242 67 239 55 70 155 230 54 93 64 229 73 139 79 178 151 287 57 150 79 219 270 273 242 289 219 285 156 180 113 211 158 177 8 86 150 256 135 255 10…
Output: 3

Example 2:

Input: 962 961 1 962 332 358 458 515 23 887 544 561 51 400 52 840 616 902 21 404 492 741 623 747 485 848 192 350 145 583 29 680 52 468 44 505 16 355 128 677 368 510 577 770 261 331 103 656 540 580 299 701 37 918 473 523 348 665 875 884 289 591 507 918 165 269 265 377 24 798 555 676 340 495 346 854 646 687 239 485 464 722 227 920 310 432 323 427 71 268 627 721 564 951 209 857 443 506 190 574 57 366 30 775 410 828 71 858 193 519 215 254 150 929 260 653 337 908 424 614 647 768 889 923 168 470 328 878 189 842 325 891 423 832 777 956 105 431 413 652 158 850 365 770 54 633 301 449 146 147 211 875 261 412 199 589 37 443 666 822 679 746 392 402 223 652 574 882 352 880 25 853 309 727 871 953 494 548 5 558 62 334 121 507 277 638 88 632 398 666 235 653 38 352 568 698 166 250 297 685 627 819 375 647 443 457 …
Output: 13

Example 3:

Input: 598 2574 1 598 379 592 60 502 300 478 455 557 313 451 85 483 197 591 43 532 116 392 69 165 29 478 104 396 279 414 195 499 202 316 47 168 354 443 211 374 87 92 91 494 361 561 125 447 158 426 246 288 429 547 96 172 320 328 195 301 38 246 100 401 308 503 118 262 314 320 297 498 326 364 448 527 540 597 42 290 90 557 259 287 8 61 147 353 185 400 76 589 262 428 192 258 134 176 76 559 103 193 2 142 99 189 96 206 114 549 306 459 241 353 66 488 24 351 221 440 365 498 26 382 66 240 457 567 40 182 217 309 278 437 140 314 428 558 366 579 88 560 364 541 429 437 65 318 109 329 492 522 2 110 145 573 292 314 366 414 385 463 16 359 95 171 122 433 30 445 233 388 2 82 192 450 155 446 374 482 18 379 173 577 42 493 28 461 270 291 20 547 43 561 17 376 255 382 350 458 216 374 138 495 178 343 264 508 19 146 119 4…
Output: 3

Constraints:

1 <= n <= 1349; 0 <= m <= 2698.

Loading...
Test Cases:No test cases
No test cases available.
Bishop's Ledger of routes - MEDIUM Coding Problem | CodeTikki