CT63557

Misty corridors Fastest Route

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the canyon post of Redrock as Wheelwright unrolls the day's manifest of corridors. The tally will decide the next shipment. 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 <= 980; 0 <= m <= 2940; 1 <= s,t,u,v <= n; 0 <= w <= 1000000000; distance fits 64-bit.

Example 1:

Input: 130 453 1 130 42 94 383082706 103 104 955589116 17 80 966628135 2 17 172322626 30 72 588577960 8 20 724809212 13 31 493426200 17 25 844943167 42 111 140295486 11 97 10108594 45 80 467194946 63 83 281830060 1 61 911822163 5 47 175375923 33 81 948753274 40 53 807936879 118 121 193675521 42 104 436234918 63 119 411427340 29 120 277335741 13 85 628514716 11 68 365001846 35 49 462383724 83 115 302584716 43 67 890825395 73 120 128954158 68 111 984287508 109 114 501152780 54 82 115604752 3 88 277550420 45 85 811168399 61 113 374835664 9 73 542362284 28 103 807536071 14 126 428646921 11 87 277880639 19 86 914857628 73 103 456028646 37 55 140563235 46 72 418865114 16 38 187988056 30 35 51911461 34 117 522456345 19 60 191811990 40 77 228924312 97 99 51350665 5 112 690569477 34 116 924870349 8 96 264…
Output: 602778791

Example 2:

Input: 455 876 1 455 159 300 423636737 184 341 170410476 209 275 791758189 27 239 473268200 58 221 754366803 225 299 815820035 149 285 294984953 77 405 252847295 350 361 694679613 51 321 982491450 189 232 150726507 46 304 541281536 48 67 197115347 262 389 122373127 90 278 107714627 110 274 358366194 81 216 202486201 143 189 2884141 306 424 91605200 18 65 87524156 73 257 46502839 28 177 167830856 159 206 599560740 16 450 435539780 118 229 82736234 49 339 354276985 214 243 465601183 248 385 33931825 123 274 318628707 121 282 440868588 66 106 269006485 55 269 427208653 56 262 850060043 171 189 680291068 123 448 432964707 399 409 721178976 29 162 690913169 3 108 308371546 43 379 382363338 277 351 599748547 181 433 240360444 47 211 864791656 71 208 571556997 384 385 582296736 236 285 914359550 181 203…
Output: 1644882080

Example 3:

Input: 48 1128 1 48 23 32 8500043 13 21 611877559 13 43 523053372 27 29 773510323 12 25 884633237 2 24 545562011 14 39 472842595 12 48 206774282 15 31 751463547 12 23 776030142 22 47 498876410 36 40 733285778 6 32 182580135 7 20 597946917 23 37 781703409 23 45 589762667 11 45 470714118 15 25 788878573 10 24 877385646 25 27 159090873 9 36 130054138 13 48 814254534 3 37 141846520 4 41 459027185 9 41 237543171 6 14 836436159 9 35 141992767 18 23 651472916 19 42 982435748 17 20 210878057 16 21 719792369 36 46 193882588 21 24 523918056 14 37 118307369 11 42 703385211 34 42 281224690 11 22 971298020 7 16 128510883 34 39 967179970 22 42 97202781 30 44 432237615 2 3 828354130 4 16 333785455 34 35 225647663 6 10 899650385 3 7 244581031 7 26 135359307 1 33 670928101 4 35 736598317 45 47 648523758 10 41 286…
Output: 92370132

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Misty corridors Fastest Route - MEDIUM Coding Problem | CodeTikki