CT42046

The tunnels at Tangledeep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the kelp forests of Tangledeep. Lakshya spreads the tunnels 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 <= 1145; 0 <= m <= 2290.

Example 1:

Input: 1144 1143 1 1144 347 424 645 920 387 458 287 342 196 617 831 850 390 987 192 639 518 661 541 795 496 578 515 1056 728 936 705 853 669 684 53 209 253 787 329 927 150 993 168 934 343 383 220 935 257 753 772 1024 90 823 202 463 101 859 624 839 223 1016 845 1125 824 1065 81 620 339 706 98 767 216 309 187 916 212 388 1039 1118 19 732 755 1144 394 508 528 1029 564 812 844 886 569 789 703 1026 316 602 1022 1061 313 679 915 1096 250 642 260 1035 521 797 186 1039 293 612 595 1079 362 1095 729 791 986 1096 134 1009 488 968 101 565 67 893 448 711 129 575 811 987 593 614 352 927 390 1038 188 1033 4 337 286 1094 60 1078 814 850 574 1128 699 806 151 542 157 761 456 1041 708 741 395 462 324 926 676 814 183 583 573 705 546 707 623 936 369 626 383 625 60 443 180 844 580 752 234 502 156 231 108 379 221 540 …
Output: 18

Example 2:

Input: 885 884 1 885 410 512 413 671 101 678 334 544 557 641 168 722 180 620 267 546 543 590 375 574 491 839 130 377 500 826 345 420 89 217 96 273 497 739 318 678 250 347 313 489 46 57 438 499 143 777 603 815 180 504 76 242 803 844 128 420 246 769 539 564 419 606 96 596 494 845 263 824 457 613 330 748 43 793 243 650 14 169 241 431 289 781 423 530 526 625 26 595 498 568 83 747 256 324 95 783 640 820 95 361 117 833 697 785 410 443 169 873 640 752 112 425 1 60 631 655 3 759 406 722 203 235 172 190 465 796 682 820 751 876 119 798 519 790 339 542 184 194 219 712 54 154 2 85 80 726 311 783 95 620 386 869 143 527 654 751 190 464 304 431 10 590 736 848 529 584 209 294 230 864 308 621 555 629 93 440 213 697 403 656 289 845 185 352 489 610 160 553 24 484 32 796 115 301 276 633 723 875 180 312 124 225 239 5…
Output: 13

Example 3:

Input: 1128 1127 1 1128 122 625 14 416 495 972 39 1045 708 1128 42 969 609 718 622 1069 536 1001 897 937 974 1052 861 882 422 676 491 939 727 830 19 1062 736 922 707 881 454 795 693 1048 312 466 469 870 614 702 730 1002 395 705 414 830 149 974 223 792 428 768 190 201 266 942 771 835 595 1020 557 573 858 948 239 366 937 968 92 191 35 792 457 576 344 463 90 880 240 1082 236 1059 316 771 261 492 134 1065 529 729 681 738 412 911 533 612 774 1082 818 1060 252 732 662 839 153 321 849 952 123 705 1017 1052 196 1041 685 972 639 843 419 557 477 848 182 341 715 1109 310 1116 246 1059 241 325 429 1106 761 924 248 713 466 545 42 272 368 670 479 784 363 395 827 913 834 981 741 1053 163 897 178 257 913 922 327 844 999 1082 398 829 121 445 943 1101 272 421 215 1087 715 716 237 533 226 421 562 837 954 1103 373 5…
Output: 3

Constraints:

1 <= n <= 1145; 0 <= m <= 2290.

Loading...
Test Cases:No test cases
No test cases available.
The tunnels at Tangledeep - MEDIUM Coding Problem | CodeTikki