CT60026

The Fastest Route of the Marble routes

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the pearl fisheries of Nacre Bay as Tinker unrolls the day's manifest of routes. 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 <= 2030; 0 <= m <= 6090; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Example 1:

Input: 309 4855 1 309 31 108 383 59 285 528 184 260 847 173 276 624 34 90 563 267 293 574 52 213 792 85 302 437 163 201 354 39 225 273 45 222 192 85 91 912 157 210 730 48 106 862 143 235 939 12 138 644 42 250 358 65 115 73 21 42 406 114 129 723 57 293 79 26 157 17 13 218 994 22 167 283 5 127 712 234 308 94 48 209 568 120 235 521 157 308 314 62 232 631 153 272 562 53 130 921 204 302 954 121 269 948 18 280 413 191 260 106 41 54 891 81 258 721 136 149 351 130 275 419 28 229 871 30 200 100 240 298 18 130 215 146 179 241 910 36 174 183 69 108 22 107 113 162 40 123 281 34 298 639 78 224 845 83 148 116 115 168 953 72 122 629 155 284 351 47 282 799 5 215 938 193 290 351 47 109 400 13 179 214 8 130 71 27 92 484 67 196 407 64 303 448 4 274 887 60 207 141 269 278 712 250 265 845 92 235 132 51 154 884 6 221 …
Output: 206

Example 2:

Input: 1687 2517 1 1687 279 370 748 69 1302 493 239 461 839 1279 1413 612 203 483 601 454 1088 17 86 197 338 98 976 642 1058 1610 368 251 914 987 111 186 283 1021 1408 738 623 1222 396 312 388 109 505 1301 575 241 434 246 53 1613 238 591 1527 361 622 1120 419 956 1153 31 582 967 217 1289 1361 573 430 1542 501 331 783 629 68 774 384 338 1483 63 497 1322 913 1478 1668 818 589 1286 717 137 400 507 95 359 99 375 1086 850 29 91 947 272 764 826 346 462 293 1227 1229 269 126 1015 598 404 1330 712 91 536 914 409 818 467 954 1558 522 961 1593 592 135 997 517 772 1111 94 718 934 290 331 399 185 430 1383 693 1156 1176 345 250 1650 759 541 593 361 55 501 766 1145 1263 883 778 859 181 676 1130 617 394 639 892 378 404 464 848 1048 554 822 1149 543 304 338 385 776 780 688 553 886 193 195 1113 410 562 1417 536 7…
Output: 1914

Example 3:

Input: 290 3385 1 290 64 151 709 88 97 850 185 222 65 57 182 293 59 205 866 48 202 222 95 134 319 68 92 485 41 180 826 83 176 32 220 289 483 54 105 459 83 137 984 161 284 819 134 187 705 13 278 679 280 281 893 99 165 608 52 179 56 88 165 690 229 241 843 10 189 833 114 149 863 28 174 681 44 186 375 63 267 201 48 179 488 209 233 715 58 63 83 86 195 760 157 201 194 101 266 362 96 234 630 203 240 602 2 268 476 45 143 413 173 244 203 24 188 75 168 253 478 63 240 912 44 195 50 229 276 575 146 263 846 208 243 844 123 144 748 12 164 650 2 101 188 167 192 808 128 272 297 144 287 923 13 168 435 132 227 72 6 14 975 166 269 289 8 182 169 266 274 676 67 134 28 147 191 299 54 282 788 192 218 778 107 203 705 64 208 859 183 276 267 95 178 391 111 202 382 79 236 559 196 270 404 187 284 672 228 277 708 138 224 556…
Output: 230

Constraints:

1 <= n <= 2030; 0 <= m <= 6090; 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 Marble routes - MEDIUM Coding Problem | CodeTikki