CT64928

Theron Counts the canals

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the beacon hill of Lantern Tor close for winter, Theron must finish the canals ledger - one figure at a time. 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 <= 865; 0 <= m <= 2595; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Example 1:

Input: 498 759 1 498 106 288 515 120 363 784 292 300 997 220 249 900 387 491 798 59 271 957 13 134 511 104 271 391 67 301 457 228 259 545 211 279 273 2 134 832 214 269 405 481 492 405 85 232 674 172 432 706 332 370 821 62 314 49 116 375 500 179 373 471 276 326 92 115 328 568 96 317 639 109 366 13 27 483 357 268 399 463 169 215 312 341 409 7 103 494 648 39 463 46 289 303 725 19 339 716 79 383 259 83 271 29 24 246 737 53 68 994 205 370 504 213 275 240 81 189 462 41 355 664 39 141 117 28 388 445 124 222 867 412 444 169 1 31 960 314 361 143 82 250 416 319 483 82 151 237 390 358 474 189 348 408 108 81 384 285 108 109 414 81 216 15 207 479 568 29 478 397 38 105 94 1 149 874 215 279 750 245 492 463 117 239 179 210 218 58 4 411 749 329 464 51 6 162 298 28 174 434 149 191 223 41 322 727 7 18 76 361 409 21…
Output: 1978

Example 2:

Input: 419 2033 1 419 74 335 321 162 230 649 242 259 874 213 315 890 337 401 876 191 353 717 7 72 88 102 167 808 51 412 179 29 107 741 251 294 879 162 268 311 1 173 112 82 341 797 168 284 585 59 162 479 34 193 855 313 413 253 100 343 488 174 338 958 282 393 145 167 353 265 128 161 171 396 419 818 89 147 62 170 275 668 16 367 826 101 257 763 113 257 214 246 249 652 11 169 710 296 364 594 379 419 354 82 386 594 84 319 254 10 262 851 138 202 816 210 290 616 151 286 276 411 418 753 154 187 183 95 158 858 81 216 236 46 204 723 304 410 598 28 133 844 360 373 389 310 341 127 36 293 393 323 376 749 26 321 355 186 226 779 85 315 824 233 307 137 46 364 927 39 321 54 32 293 258 24 377 973 345 364 739 117 346 358 158 316 705 19 132 401 269 322 606 173 300 486 244 273 84 243 397 617 16 339 854 104 327 53 15 3…
Output: 513

Example 3:

Input: 265 264 1 265 24 171 870 151 175 724 26 176 435 13 32 570 164 238 868 82 106 650 134 236 231 173 192 874 151 159 531 159 171 116 23 234 392 51 249 592 59 147 337 16 144 407 46 179 990 49 178 445 16 153 817 30 96 71 50 239 75 178 226 474 145 237 482 216 243 35 2 91 708 4 198 617 35 74 191 83 152 637 7 184 771 206 242 872 108 115 661 67 140 758 91 232 645 21 210 70 65 72 879 4 132 122 43 186 700 118 225 821 99 123 461 135 194 350 39 145 719 9 235 392 206 261 566 95 190 661 55 127 1 99 231 501 41 46 512 42 46 836 94 232 86 213 264 168 97 238 722 134 207 643 68 228 728 66 68 56 12 71 158 196 199 763 14 149 690 33 250 91 66 169 94 26 139 562 2 219 603 175 252 839 153 263 813 156 207 743 34 265 827 41 260 590 90 161 487 30 263 935 58 159 359 189 230 102 159 162 688 121 199 885 212 263 783 56 117…
Output: 1639

Constraints:

1 <= n <= 865; 0 <= m <= 2595; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Loading...
Test Cases:No test cases
No test cases available.
Theron Counts the canals - MEDIUM Coding Problem | CodeTikki