CT63301

Cora's Ledger of tunnels

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the seal rocks of Barking Cove, Cora the reckoner keeps careful count of the tunnels. outscore the rival chapter, every figure matters. 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 <= 1219; 0 <= m <= 3657; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Example 1:

Input: 785 2677 1 785 183 566 305 312 414 324 296 541 832 129 709 417 91 777 824 69 175 333 19 284 586 460 475 213 289 641 271 8 241 485 128 189 488 100 743 233 311 538 600 724 747 3 76 776 621 103 430 592 151 271 365 248 645 579 269 470 577 268 723 485 239 397 256 125 397 91 242 372 205 38 756 798 82 343 724 118 345 165 39 601 884 212 645 849 159 338 88 63 764 521 498 624 38 131 540 856 494 673 329 188 669 992 397 629 619 354 747 510 156 423 585 146 604 74 653 753 668 230 311 389 425 519 937 256 595 432 4 9 19 466 657 119 439 526 255 163 491 987 21 580 440 156 303 367 201 293 939 37 738 536 33 444 300 71 173 866 81 691 561 390 778 456 128 433 611 70 233 918 40 349 242 108 607 824 244 735 583 290 357 467 175 265 772 250 535 200 57 337 808 578 660 911 320 740 775 298 553 977 327 340 228 329 413 54…
Output: 1178

Example 2:

Input: 850 3297 1 850 208 466 727 83 94 92 32 584 915 411 490 484 715 837 544 5 399 518 9 241 308 443 533 854 653 784 58 138 220 488 298 736 112 6 293 910 641 787 135 406 528 833 231 621 473 64 132 111 174 348 399 370 386 680 547 699 146 539 688 441 463 835 563 360 732 635 2 633 718 323 606 475 679 730 843 100 430 515 12 504 665 206 584 696 125 450 344 165 405 508 49 414 568 112 377 711 419 523 258 150 499 760 47 386 309 753 794 865 428 591 749 47 504 714 482 579 348 217 741 908 25 146 114 385 843 326 431 647 318 243 495 172 739 802 475 186 658 753 129 603 299 114 429 64 41 623 649 421 640 781 358 610 631 149 347 13 290 453 222 608 810 266 569 802 576 67 305 979 677 845 130 69 817 523 326 799 680 449 734 315 147 731 625 532 800 444 494 506 48 157 591 692 89 752 282 484 666 701 153 222 67 185 292 …
Output: 204

Example 3:

Input: 327 2779 1 327 94 172 60 81 292 788 254 315 47 93 230 602 208 221 589 112 220 500 106 217 586 22 207 379 26 325 402 80 126 896 46 291 863 29 187 857 312 324 976 52 78 249 11 236 433 54 286 495 10 303 713 182 256 119 72 191 969 159 282 299 33 324 80 186 208 414 30 226 775 123 137 144 121 152 292 86 107 343 148 269 701 44 290 367 212 257 844 88 261 359 109 138 627 219 325 909 127 179 912 216 323 718 1 206 904 70 318 818 149 299 866 259 266 113 165 274 514 246 320 380 211 299 268 1 192 482 29 44 644 263 311 686 47 169 690 152 276 269 50 175 688 184 242 448 82 181 610 52 258 431 107 316 803 15 261 286 79 274 617 181 184 389 100 324 731 58 206 797 70 90 412 105 154 768 199 324 990 107 152 44 5 256 438 122 292 838 218 236 8 208 318 704 15 133 727 192 322 543 220 277 613 257 274 206 35 307 230 12…
Output: 408

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Cora's Ledger of tunnels - MEDIUM Coding Problem | CodeTikki