CT61519

The Fastest Route at Whitestone

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the alabaster quarry of Whitestone pays by the answer, and Jessa intends to earn it. First: the full register of routes. 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 <= 894; 0 <= m <= 2682; 1 <= s,t,u,v <= n; 0 <= w <= 1000000; distance fits 64-bit.

Example 1:

Input: 560 2063 1 560 144 249 638445 379 517 323350 323 447 537384 187 256 173996 142 197 414529 41 326 762907 337 449 488409 25 525 102158 128 481 94196 143 518 437618 164 393 294877 438 506 58336 332 430 640498 144 413 560510 322 466 951274 299 419 334101 464 528 199838 58 534 645613 136 277 98631 186 406 92331 246 349 104099 469 537 216164 267 280 743276 398 519 242622 335 507 984091 179 449 851233 256 445 918777 74 388 310108 9 243 605857 329 468 816544 123 481 386206 13 178 727548 36 117 910521 110 210 303521 440 486 120488 51 324 150375 107 124 437344 141 172 4237 341 523 965204 194 261 785181 72 400 12931 134 411 736103 205 383 522483 86 517 908633 122 474 152066 345 353 758093 126 505 489961 32 83 5229 283 486 480855 380 407 310420 206 246 486930 30 482 69991 461 480 129153 106 191 405237…
Output: 1067611

Example 2:

Input: 101 2402 1 101 19 83 316589 11 28 888847 93 94 142895 32 81 303074 73 101 514388 73 92 470626 24 71 200472 14 47 193954 50 62 176666 47 82 322526 39 91 207054 5 27 547276 34 85 205653 38 80 877969 12 79 438152 63 65 911059 62 66 387289 72 82 90713 18 24 775865 5 58 939937 2 54 128856 11 35 8447 2 71 828117 4 57 215224 61 77 380617 70 83 368974 4 92 546331 60 96 376273 20 86 227497 45 93 794284 4 83 634942 17 27 414583 47 73 475661 33 54 332525 46 92 628877 72 101 949554 42 70 554985 67 68 350320 23 59 655214 4 72 121914 8 45 541187 62 77 244565 42 56 284531 36 81 946680 37 51 666870 5 34 553548 29 100 195601 52 91 478528 33 70 592927 48 85 512927 80 99 186824 16 18 632418 58 97 612696 27 40 16754 19 43 273935 1 82 553307 32 47 741440 81 83 858551 18 28 710769 40 61 49972 2 84 586959 67 97 …
Output: 137313

Example 3:

Input: 482 2544 1 482 107 313 116010 93 202 457206 171 180 749092 438 470 725577 177 231 678497 191 326 782258 118 334 959467 241 469 501534 127 407 277688 413 431 453385 113 354 865310 66 175 877440 251 360 519555 222 461 84383 389 454 430577 143 396 132532 156 240 363036 206 366 743205 147 295 516781 145 167 750980 161 416 679561 296 327 725366 356 363 501583 233 332 287802 335 435 3816 381 465 45638 83 436 624045 131 296 733873 32 47 98188 88 127 935323 80 134 258511 218 285 209834 341 408 387248 84 340 129473 295 327 821386 299 443 55771 264 373 860826 38 445 494538 151 402 265362 118 413 941656 70 380 518507 237 336 30938 56 381 829234 75 191 421724 166 393 69675 378 450 629543 234 384 988435 118 193 177218 225 325 642385 151 463 402371 189 403 955481 351 437 904398 159 176 998846 217 291 83…
Output: 508517

Constraints:

1 <= n <= 894; 0 <= m <= 2682; 1 <= s,t,u,v <= n; 0 <= w <= 1000000; distance fits 64-bit.

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