CT62282

The Fastest Route of Cindercrag

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the ember mines of Cindercrag, Chetan studies rows of bridges entries. One clean number will settle the guild's oldest argument. 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 <= 1118; 0 <= m <= 3354; 1 <= s,t,u,v <= n; 0 <= w <= 1000000000; distance fits 64-bit.

Example 1:

Input: 877 2448 1 877 115 142 39725291 186 811 629754017 488 702 178528454 90 760 803319400 38 796 471883747 98 187 778908464 849 875 133358222 70 520 971400560 184 820 34873419 39 827 145664967 204 445 572943287 75 220 226377923 337 816 56684072 495 790 709801395 146 394 656208628 236 536 579628039 28 633 837721355 68 411 959203084 266 513 443202696 91 796 273746854 484 834 846954606 172 707 332771676 120 185 827372319 37 700 12416862 197 759 786571268 237 852 869325150 373 489 236776261 529 639 686442504 520 674 258067377 3 57 247471687 233 823 666968976 459 818 940197028 120 332 19425638 455 592 740876196 264 729 641239158 272 579 137973743 190 656 614070862 577 662 922077338 207 209 41273387 182 678 370513054 68 136 63899026 128 189 134483878 299 590 90132328 548 862 237187009 617 703 3622056…
Output: 1443341166

Example 2:

Input: 938 2520 1 938 579 772 960989327 133 914 345005287 732 766 875830292 132 146 577907926 597 851 173171953 417 826 696560490 282 328 255917084 383 473 967249096 220 779 255156034 123 691 819158263 42 266 329055847 586 712 33337970 161 245 962375242 718 868 276600354 199 243 114481851 215 668 696424962 239 765 666573900 463 534 608754156 492 810 137762578 179 743 960140026 95 306 171631453 281 924 33053705 264 786 42987664 557 839 951152387 283 522 195742853 360 899 79070151 41 384 461190026 88 576 795119699 133 373 940274030 202 301 981379429 470 699 349814883 157 320 524994924 309 402 476065978 790 802 538985987 447 487 198018014 383 611 539401435 112 294 905067539 235 541 125472746 596 855 162823566 562 656 785079569 558 562 3629486 32 540 180364344 354 928 884594485 340 674 91383108 410 8…
Output: 1223975655

Example 3:

Input: 887 1291 1 887 371 593 778944738 446 677 274432540 563 773 528571504 42 867 217665240 294 601 621407608 101 774 727322709 381 436 847460357 464 496 51622181 150 846 876468773 273 394 5364818 33 703 431047501 94 774 716482089 271 544 100231550 37 303 999371585 339 559 945940525 28 604 232178801 361 422 944434235 436 597 55233242 690 711 955481258 305 752 557811195 57 762 702496043 348 724 935072157 632 784 931175483 66 507 218724011 659 818 577581244 635 677 837661598 415 885 679338680 49 806 217911714 558 809 51640759 209 638 920233125 351 501 783849638 317 445 296277785 118 167 595536266 526 716 938234401 798 825 474127401 454 556 233433674 246 436 654626159 186 610 42998932 163 178 532349370 564 701 18814509 89 248 776592260 204 855 304231899 308 615 834722533 285 382 134180607 273 516 8…
Output: 2958572232

Constraints:

1 <= n <= 1118; 0 <= m <= 3354; 1 <= s,t,u,v <= n; 0 <= w <= 1000000000; distance fits 64-bit.

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