CT44999

Blythe's canals Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the garden city of Petalbrook; Blythe weighs the day's canals manifests and starts the calculations. Task: An undirected weighted graph is given. Print the shortest-path cost from s to t, or -1 if unreachable. Input format: First line: n m s t. Next m lines: u v w. Output format: Print the shortest distance or -1. Constraints: 1 <= n <= 1186; 0 <= m <= 3558; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Example 1:

Input: 664 2807 1 664 281 455 730 190 439 118 154 269 920 130 285 948 121 141 118 46 269 945 359 510 472 55 400 526 139 521 431 33 326 683 86 512 731 367 578 734 496 518 685 1 338 732 243 551 673 115 261 585 171 364 339 442 664 989 124 410 959 156 602 508 37 124 40 65 266 65 259 469 601 167 387 448 174 247 598 100 452 751 33 536 76 398 413 234 51 636 730 330 471 395 130 524 522 98 520 547 24 161 32 133 253 23 73 448 469 269 589 687 463 501 619 9 630 204 83 567 797 7 616 424 51 447 273 49 163 404 62 354 922 402 597 523 651 657 941 405 581 471 538 647 199 38 249 139 392 524 657 16 83 492 228 495 570 79 252 707 133 393 629 113 406 340 282 509 649 194 495 321 24 577 924 24 515 960 170 188 601 110 646 501 283 622 64 435 595 756 400 527 679 525 581 164 208 333 872 72 437 285 59 531 969 330 585 830 54 1…
Output: 979

Example 2:

Input: 143 274 1 143 89 141 492 35 62 747 49 101 931 65 110 897 70 143 664 8 109 615 92 139 225 21 48 914 37 69 938 21 113 155 37 58 597 41 129 667 43 139 320 53 63 833 51 65 617 29 44 781 104 135 797 55 63 33 8 52 783 50 66 660 15 31 889 16 41 491 14 140 779 2 68 388 77 95 929 17 130 676 17 129 796 17 95 223 18 119 641 9 50 607 97 111 905 37 142 722 129 134 903 79 111 149 91 101 385 17 109 443 1 135 744 41 43 913 97 115 154 17 76 64 112 127 65 42 135 684 41 93 44 15 39 276 5 88 8 91 138 982 54 142 446 15 119 946 7 62 507 28 45 428 23 137 486 84 113 854 80 99 939 54 127 333 100 120 10 62 71 141 34 107 932 77 92 753 25 139 410 15 88 181 57 69 596 87 118 73 21 95 689 5 114 642 67 103 205 50 120 723 27 84 538 3 86 996 61 95 711 69 80 184 10 105 288 25 103 261 28 87 296 6 46 940 6 26 587 77 126 657 7…
Output: 1727

Example 3:

Input: 1131 2937 1 1131 707 723 42 115 979 343 503 731 674 127 510 165 571 1109 651 528 816 842 167 777 260 212 747 569 101 594 488 207 923 874 2 527 443 577 916 52 169 623 79 787 921 627 733 897 370 809 850 57 566 772 228 448 1119 523 259 574 767 158 1022 61 324 384 661 505 782 338 492 856 356 422 574 822 274 578 607 736 854 403 823 1036 285 36 862 693 872 952 483 833 859 145 97 663 61 188 907 65 568 845 979 771 779 41 158 197 989 13 108 786 43 1083 465 351 1087 274 342 560 169 220 918 631 8 342 855 186 1131 759 70 782 869 894 974 641 573 694 498 841 886 861 357 433 580 974 1116 689 603 718 299 201 563 459 129 869 305 332 544 139 740 846 236 790 935 602 16 67 537 206 340 949 363 1070 278 321 1028 889 115 714 639 884 1081 867 309 851 240 232 311 574 21 564 39 825 1012 98 418 645 173 643 684 653 4…
Output: 1247

Constraints:

1 <= n <= 1186; 0 <= m <= 3558; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

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