CT62951

The Fastest Route of the Beryl bridges

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the lantern reef of Glowtide, Kavya the factor keeps careful count of the bridges. Schedule the next expedition, every figure matters. 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 <= 1017; 0 <= m <= 3051; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Example 1:

Input: 136 460 1 136 74 135 946 16 55 336 56 99 925 76 135 798 1 22 435 37 106 127 57 134 866 61 127 639 106 129 410 54 88 698 27 114 725 55 85 700 38 107 17 68 98 500 25 38 823 32 120 861 74 102 790 66 117 761 20 113 278 10 55 389 57 117 532 100 108 410 44 116 392 60 100 878 31 82 779 46 68 80 58 68 813 111 125 435 20 64 301 28 59 985 54 85 25 106 131 901 68 115 998 8 122 133 37 136 429 51 52 515 47 109 310 11 45 927 41 100 827 77 113 41 5 31 813 68 69 125 19 120 913 46 83 826 1 111 902 95 97 126 45 134 752 56 94 761 27 136 282 10 123 303 33 108 212 43 106 47 41 69 163 69 103 620 118 136 600 63 124 102 87 91 5 38 108 317 35 66 856 45 92 495 32 135 602 22 29 618 74 109 373 55 127 684 68 86 604 14 123 480 6 63 67 2 15 565 22 87 897 31 77 52 87 129 436 57 132 874 65 98 179 52 60 898 85 117 295 9 12…
Output: 444

Example 2:

Input: 891 2608 1 891 639 727 245 520 641 150 82 680 87 90 172 683 264 686 774 173 201 330 171 529 175 249 485 478 260 459 744 205 779 16 768 794 303 694 766 780 727 873 56 768 858 360 23 866 359 709 731 888 58 248 153 480 775 419 13 28 522 100 559 163 94 615 571 540 562 939 66 113 654 210 796 623 371 884 907 538 569 772 445 620 153 278 743 624 60 737 42 56 484 649 102 309 489 187 248 292 280 843 240 192 432 75 69 860 197 211 858 342 303 501 607 442 621 82 320 671 768 16 53 606 529 812 501 332 429 735 35 269 845 92 503 936 296 468 915 266 765 817 135 326 870 376 666 886 279 865 797 316 806 175 322 691 89 48 701 367 23 113 655 461 850 717 193 499 97 402 571 147 121 459 146 496 602 694 135 846 809 338 725 287 436 853 517 520 623 580 689 780 932 124 850 594 390 565 511 242 721 253 30 784 428 371 563…
Output: 522

Example 3:

Input: 494 2798 1 494 73 193 654 176 197 188 252 301 300 198 284 625 119 273 389 303 464 291 133 204 482 290 350 315 340 392 387 52 384 694 287 457 319 24 245 326 6 76 233 322 365 1 300 355 447 389 432 736 192 386 259 87 455 602 191 292 408 137 141 537 444 468 76 230 375 531 148 448 605 99 279 879 197 331 542 245 281 164 312 395 107 31 390 925 250 299 183 131 321 567 59 290 946 72 485 194 34 114 264 418 470 281 402 493 901 203 373 502 228 385 523 221 444 51 365 368 619 115 124 111 206 266 880 16 465 546 20 24 122 40 249 857 55 74 449 74 490 729 141 335 935 207 289 117 235 347 233 222 471 847 28 62 970 346 372 717 268 305 204 137 270 511 52 162 936 254 438 73 192 452 497 165 466 579 319 360 193 259 319 277 197 333 373 96 99 537 299 372 373 13 102 214 14 463 189 227 406 649 105 136 54 232 478 752 1…
Output: 359

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Fastest Route of the Beryl bridges - MEDIUM Coding Problem | CodeTikki