CT62784

Wamika's roads Reckoning

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the rookery of Crowhaven; Wamika weighs the day's roads 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 <= 875; 0 <= m <= 2625; 1 <= s,t,u,v <= n; 0 <= w <= 1000000000; distance fits 64-bit.

Example 1:

Input: 55 1125 1 55 10 33 10159701 7 31 760143680 11 30 426655158 3 9 799637426 47 54 692620821 2 9 28837287 34 36 298855408 3 45 316054090 33 34 737042451 4 31 907268133 34 45 562607878 13 50 870569989 10 36 592583362 28 41 512437506 3 26 204539274 1 20 847658943 37 46 973431114 21 52 22388489 26 39 257735857 13 20 701519866 9 37 578251887 19 31 922922661 31 51 895028912 8 52 315640048 22 47 815459197 21 30 644248632 26 38 775179455 27 49 857706993 17 48 218545817 23 31 241482738 13 52 405130357 1 42 149010887 19 24 692217820 29 44 751409664 36 48 427240476 7 38 440320003 23 43 666080914 25 32 369990369 52 53 790180564 4 23 409968112 16 26 531864452 2 37 400570585 17 46 241715226 23 53 759479286 11 20 108499892 40 52 277701799 20 34 628212313 17 37 565095201 9 43 594105462 9 15 580832405 3 54 39…
Output: 95002042

Example 2:

Input: 164 429 1 164 29 124 584601657 71 99 41190563 77 97 899380130 8 14 607311081 48 144 464960414 23 154 303502675 96 121 635474367 82 121 423068315 90 155 797774765 67 121 124987639 28 156 942586368 150 158 811904328 8 125 740726622 5 39 272757200 53 142 773037375 27 105 142782710 2 130 957114523 90 141 954008470 56 122 7300996 43 106 99991992 54 144 877647074 88 134 61383831 57 110 576198441 21 69 44454964 32 73 426306846 21 128 631472418 3 79 18674954 41 151 515006137 46 76 897485263 73 151 740219119 105 142 945599662 6 147 682332027 151 153 543450566 69 92 428826127 110 141 404757689 16 81 119607294 6 12 676380054 21 113 455570256 98 109 701679080 114 118 956878631 8 137 916038675 46 152 240563359 44 115 566096368 43 157 802709389 60 83 433379629 74 90 21842902 14 117 378867205 97 105 8325…
Output: 1036222570

Example 3:

Input: 313 1354 1 313 97 244 454193879 82 249 78743122 126 139 110274549 100 290 645535222 57 97 287129147 3 210 918343963 220 285 897362369 27 167 836655419 212 296 491207501 121 180 654246625 5 55 383159067 53 246 805323407 44 52 254021278 16 290 227449517 2 309 715849711 137 208 320386465 115 148 720759338 203 222 586246145 255 279 842157284 44 272 929292612 187 300 759102728 72 187 753963707 7 51 903471198 225 257 625544312 2 149 715962006 90 167 171876247 65 71 875526913 76 155 635280214 14 105 977715924 123 253 929639937 8 206 783771327 170 178 372297964 112 204 894309462 165 184 14222501 94 106 309119572 180 220 343175434 139 142 620565102 71 217 78094518 279 283 31935253 31 195 514146901 19 251 907880683 85 274 871297056 168 256 412133395 18 157 979176275 180 210 716478681 86 136 96104103…
Output: 1004652087

Constraints:

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

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