CT59757

The Scriptoria Fastest Route

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the ink district of Scriptoria close for winter, Chavi must finish the bridges 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 <= 1379; 0 <= m <= 4137; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Example 1:

Input: 392 391 1 392 75 121 705 31 292 233 172 237 504 31 92 969 225 343 197 64 204 225 31 338 242 63 272 385 140 226 663 89 212 992 173 209 472 5 35 26 14 97 654 325 328 436 56 173 815 89 320 293 212 265 238 60 346 544 147 357 973 184 189 806 165 373 738 212 219 383 108 316 221 26 129 447 109 372 23 188 230 835 214 370 833 22 33 991 30 317 180 161 391 48 19 163 794 187 340 165 279 362 907 11 160 738 130 365 966 51 336 832 127 173 147 239 279 460 90 285 937 45 317 81 68 128 294 68 382 858 292 366 431 95 124 486 205 267 437 19 143 943 62 268 161 78 225 63 379 384 669 376 392 574 153 194 251 151 291 408 163 319 66 43 341 591 71 132 755 236 253 376 15 245 188 83 111 390 32 329 279 24 384 478 140 332 276 96 112 218 93 341 736 58 358 238 132 230 394 80 118 9 38 194 22 27 115 708 249 364 75 102 139 11 …
Output: 7313

Example 2:

Input: 282 1385 1 282 66 145 302 171 249 471 86 96 159 140 266 636 21 65 105 171 265 121 3 32 723 241 276 572 93 234 985 16 226 335 218 259 854 18 198 606 205 253 647 124 241 725 195 200 416 249 254 75 52 203 602 211 264 853 127 183 811 98 152 836 148 243 320 64 229 4 21 247 232 107 133 369 145 232 23 119 255 91 218 231 769 68 233 949 160 187 372 184 228 23 51 263 349 69 147 289 176 205 205 41 132 473 46 207 351 44 105 339 199 256 734 124 278 412 5 269 353 138 275 531 121 167 734 220 240 231 68 191 295 19 262 26 100 174 804 138 143 242 76 274 754 38 78 420 221 280 101 110 187 79 39 186 324 161 164 149 217 219 804 138 228 755 243 253 19 28 71 558 152 199 175 99 248 322 99 171 646 96 280 122 87 252 809 131 166 461 210 262 506 141 260 586 188 255 155 59 136 809 39 180 443 140 205 747 186 281 990 202…
Output: 858

Example 3:

Input: 528 527 1 528 57 233 452 284 447 900 251 398 124 166 223 302 65 183 459 38 217 451 35 157 315 302 323 666 362 452 450 368 501 726 146 463 126 73 354 742 233 289 842 278 294 772 219 343 308 88 521 294 147 408 752 5 468 513 253 298 55 112 191 556 410 421 178 414 457 842 156 507 481 210 502 853 449 490 273 166 178 328 42 253 771 462 479 40 26 104 331 145 441 22 166 376 948 89 524 211 77 231 957 23 260 612 406 421 512 86 289 148 223 477 620 38 424 640 39 72 95 198 482 957 57 87 327 272 495 896 381 507 691 137 344 355 179 417 181 148 174 750 98 363 654 214 427 156 419 448 980 174 377 949 116 365 405 100 171 253 164 307 505 121 278 884 48 52 945 150 208 869 126 144 333 312 485 991 65 251 176 230 333 524 62 397 298 122 127 408 38 78 30 350 374 388 286 441 806 314 480 637 37 170 370 39 369 568 22 …
Output: 7775

Constraints:

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

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