CT52030

Orin and the Crimson corridors

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the mushroom groves of Fungaldeep with crates of corridors, and Orin the assayer must account for every last one. 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 <= 3011; 0 <= m <= 6022.

Example 1:

Input: 732 1474 1 732 17 136 215 538 703 722 148 286 310 437 50 481 402 450 654 700 125 504 244 324 440 700 51 577 463 636 300 589 281 607 82 329 261 435 505 537 154 511 173 485 211 646 187 189 337 410 184 490 149 558 100 274 276 537 278 631 234 565 517 671 78 539 294 449 306 413 183 723 227 527 483 633 201 379 426 490 348 373 566 679 159 288 389 598 164 208 305 412 99 491 131 415 545 710 172 399 382 587 39 436 294 442 324 382 82 614 131 307 74 417 5 648 14 416 16 487 62 637 190 652 278 576 445 512 156 517 213 699 144 679 342 414 157 427 75 517 182 526 391 652 12 214 149 274 14 530 132 320 161 364 55 547 410 620 310 322 62 249 41 730 197 361 50 602 428 715 7 17 505 617 185 614 437 693 477 483 175 449 598 636 13 64 373 718 23 285 108 671 548 571 219 476 256 449 339 471 7 161 591 647 443 477 215 37…
Output: 4

Example 2:

Input: 796 4312 1 796 323 720 338 428 216 469 116 452 10 531 391 656 6 708 716 788 229 505 533 726 160 525 67 727 66 466 388 595 546 547 615 733 22 301 17 294 187 755 53 569 5 327 501 692 86 757 262 381 524 589 76 377 110 447 242 496 266 313 52 533 70 136 482 761 121 313 205 243 153 358 532 614 523 589 283 780 72 440 107 342 646 790 20 719 279 496 383 488 627 746 1 177 390 590 60 389 15 188 343 649 293 627 18 709 426 627 652 695 441 700 278 616 465 752 436 765 307 405 389 527 279 479 539 679 254 770 169 270 32 308 84 552 574 599 92 367 14 192 600 642 168 720 528 552 338 495 286 641 362 549 127 697 110 402 60 197 262 439 8 418 543 613 217 451 423 796 385 632 430 614 21 719 14 213 112 769 160 203 138 222 368 594 390 548 46 155 465 759 296 310 606 648 149 355 387 412 48 375 137 178 176 789 92 474 11…
Output: 3

Example 3:

Input: 2430 5780 1 2430 805 1850 953 1401 21 142 563 1302 711 1730 1349 1791 1397 2073 443 2407 948 1326 1078 1439 273 1316 124 975 497 2308 519 756 1193 2399 2016 2413 138 563 798 943 598 1363 46 2054 252 430 649 723 540 596 96 1086 130 571 1023 1038 1372 2026 466 1959 74 1205 124 1175 873 1264 645 1925 1881 2316 1989 2348 90 1774 1413 2049 341 1040 1469 1898 379 1544 270 1345 1418 1793 375 905 318 1294 803 2013 1373 1827 1923 2347 262 2038 830 2194 885 1223 1852 1855 346 540 1238 1755 598 1844 510 1370 1957 2326 1474 1589 140 691 362 2286 479 661 528 1953 1678 2228 843 1980 880 2051 771 1805 70 548 126 363 1396 2182 515 1823 1211 2429 14 340 1257 1987 610 619 1544 2162 1274 2415 1680 1939 2245 2396 304 1046 835 1181 942 2042 1802 2164 1117 1887 1111 2245 47 1858 336 1941 228 282 170 1677 1608 2…
Output: 5

Constraints:

1 <= n <= 3011; 0 <= m <= 6022.

Loading...
Test Cases:No test cases
No test cases available.
Orin and the Crimson corridors - MEDIUM Coding Problem | CodeTikki