CT65119

The Fastest Route of the Faded bridges

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Caravans arrive at the honeycomb cliffs of Beeswick with crates of bridges, and Jaya the cartographer must account for every last one. 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 <= 1845; 0 <= m <= 5535; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Example 1:

Input: 586 2450 1 586 292 550 441 456 510 815 85 132 381 154 376 512 359 530 790 4 166 540 296 299 822 40 545 932 338 459 4 290 347 534 129 573 682 13 34 584 98 359 297 170 515 444 241 446 154 266 315 229 88 135 493 201 483 823 302 512 288 175 502 341 56 573 664 516 567 488 107 517 379 13 476 242 69 196 101 127 464 429 109 193 106 188 385 80 144 226 723 365 553 196 189 278 362 376 491 372 47 521 934 331 417 369 308 327 760 280 469 699 369 407 471 219 465 158 25 484 211 70 573 44 9 483 164 379 431 306 444 519 802 282 552 689 328 576 263 129 313 653 160 398 968 218 369 503 50 173 2 31 246 785 28 459 384 446 528 223 15 96 281 221 312 8 265 478 437 212 435 625 222 476 203 103 430 457 286 311 209 161 554 823 393 488 359 400 581 345 174 358 565 274 285 618 119 231 441 356 414 428 316 339 65 551 572 207…
Output: 621

Example 2:

Input: 552 2258 1 552 235 475 900 185 395 338 44 455 436 437 442 867 493 497 572 327 361 988 278 359 266 67 219 178 129 152 7 74 231 269 275 321 654 15 122 334 100 360 789 82 178 575 335 416 863 17 173 916 313 411 50 141 279 850 6 111 272 73 229 615 46 449 10 159 481 794 136 396 493 395 412 428 391 506 380 88 327 449 394 454 257 305 394 938 123 471 84 25 547 393 239 515 578 305 548 382 15 390 176 305 355 198 381 449 763 60 406 609 260 494 951 449 478 830 180 457 395 75 439 240 411 433 294 19 266 754 60 151 265 129 275 98 4 92 447 417 505 784 430 444 230 63 220 780 11 139 24 417 424 880 99 517 520 24 286 685 21 68 854 268 416 944 293 321 536 31 330 505 168 287 9 220 433 855 20 461 545 161 301 289 177 236 392 147 223 252 148 169 830 145 197 742 271 428 552 105 458 298 160 321 914 33 84 651 143 377 …
Output: 624

Example 3:

Input: 594 1257 1 594 239 346 681 174 196 95 493 593 385 20 378 141 28 218 739 23 306 279 221 548 911 275 276 53 204 218 620 314 335 726 96 261 28 205 336 430 123 213 392 186 231 853 44 274 236 277 406 339 64 267 51 251 339 618 268 590 853 239 576 621 62 183 755 5 560 646 67 76 590 174 279 642 301 378 605 59 143 900 15 225 972 495 506 795 316 462 206 418 522 651 413 427 6 140 222 372 244 484 881 185 406 264 257 537 759 43 71 390 173 386 920 233 372 772 268 572 486 463 517 823 64 155 483 64 301 874 313 587 732 42 572 228 95 541 155 320 392 377 180 416 397 331 460 641 258 368 209 198 445 198 476 485 349 45 102 96 112 352 629 99 289 988 107 130 87 372 467 427 87 225 804 77 264 269 102 128 981 257 452 210 331 434 957 56 317 74 207 515 44 287 569 693 412 534 437 24 134 69 65 290 671 284 415 108 456 58…
Output: 1581

Constraints:

1 <= n <= 1845; 0 <= m <= 5535; 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 Faded bridges - MEDIUM Coding Problem | CodeTikki