CT33925

Odin's Quiet Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the honey farms of Buzzwell, Odin records each routes in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1031; 0 <= m <= 2062.

Example 1:

Input: 987 986 1 987 293 820 12 130 570 607 165 937 517 708 11 871 16 314 98 512 24 395 34 966 321 664 360 798 15 106 233 499 311 448 240 798 100 281 142 340 433 733 802 876 489 852 286 504 357 573 207 913 8 940 655 928 46 484 712 931 344 953 327 973 75 338 406 807 182 207 475 767 74 591 41 517 236 442 319 951 454 472 274 511 400 749 255 815 67 153 200 979 35 46 160 979 810 951 399 441 206 446 304 821 747 776 117 801 715 822 553 825 291 567 186 480 617 927 376 976 75 620 843 900 432 839 65 291 221 945 300 408 762 828 92 382 8 26 218 312 107 774 78 886 517 764 344 915 218 683 489 920 464 504 663 975 2 895 82 570 325 737 388 913 285 417 279 292 410 509 37 544 621 728 866 891 100 971 556 654 181 944 389 925 122 140 113 785 196 734 487 671 28 920 63 161 117 913 237 494 607 955 350 866 427 433 697 783…
Output: 7

Example 2:

Input: 840 839 1 840 144 763 399 566 422 429 480 660 687 728 724 826 254 310 160 598 235 444 86 527 295 397 719 727 291 765 163 237 64 115 471 559 405 682 65 157 180 621 122 306 249 795 241 784 310 448 367 487 269 837 367 621 401 710 25 240 279 532 300 378 147 159 243 595 210 732 91 374 137 658 243 620 373 545 49 79 38 813 511 570 343 698 276 510 294 327 16 277 428 785 65 105 417 489 87 769 741 754 57 591 60 129 500 751 499 506 278 721 25 598 420 478 3 679 120 570 536 587 412 742 170 258 234 619 224 812 26 126 722 822 127 419 353 494 612 621 66 335 25 175 655 793 192 807 549 661 615 715 65 466 424 597 110 556 440 828 297 526 72 822 472 728 278 684 135 282 306 804 123 269 247 719 119 323 172 200 76 146 29 278 553 637 488 686 388 576 303 326 350 544 304 566 93 297 375 526 756 790 599 696 589 836 36…
Output: 12

Example 3:

Input: 7 21 1 7 2 5 4 5 5 6 4 6 1 7 6 7 3 6 2 6 2 3 3 4 1 4 3 5 3 7 4 7 1 2 2 4 1 5 5 7 1 6 1 3 2 7
Output: 1

Constraints:

1 <= n <= 1031; 0 <= m <= 2062.

Loading...
Test Cases:No test cases
No test cases available.
Odin's Quiet Ledger - MEDIUM Coding Problem | CodeTikki