CT40503

Zephyr's Wild corridors

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the snowberry thicket of Winterholt as Zephyr unrolls the day's manifest of corridors. The tally will decide the next shipment. 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 <= 1567; 0 <= m <= 4701; 1 <= s,t,u,v <= n; 0 <= w <= 1000; distance fits 64-bit.

Example 1:

Input: 1049 1048 1 1049 604 993 318 511 525 96 295 532 49 560 801 489 817 1020 575 692 955 888 366 690 730 352 620 452 190 726 387 259 707 28 282 569 705 1 193 929 237 627 805 80 717 763 319 928 859 122 902 747 502 865 805 637 861 556 612 977 867 345 720 533 42 217 427 167 412 977 288 1028 198 11 513 736 153 807 637 883 989 406 7 937 718 468 593 919 807 849 384 424 694 589 562 651 452 564 813 528 511 604 575 93 378 892 249 764 124 275 750 266 59 167 910 406 847 396 1 686 873 500 540 544 542 791 447 334 953 622 59 1004 209 78 692 466 297 670 2 23 88 295 711 921 772 85 525 333 613 856 305 578 847 763 557 888 710 355 940 743 155 638 719 720 981 722 132 173 265 14 731 160 449 786 213 619 861 384 138 205 445 153 302 409 306 732 293 60 357 899 709 901 934 457 876 471 285 928 367 872 884 579 347 1001 82…
Output: 8033

Example 2:

Input: 1144 1729 1 1144 416 592 390 409 782 996 329 933 522 296 384 809 40 110 592 346 1142 645 95 500 444 210 1038 518 281 969 832 152 670 100 39 1136 729 811 815 175 38 391 626 314 1098 593 104 269 802 223 971 654 176 710 34 515 638 10 151 277 635 21 254 500 397 1139 275 158 749 431 494 862 693 933 952 76 623 665 178 47 1087 39 859 1127 641 94 651 684 107 948 289 284 795 963 6 250 880 355 428 699 355 868 971 832 853 182 44 1005 848 180 404 369 83 522 395 71 535 485 609 905 362 159 449 123 921 948 405 671 882 695 133 957 592 603 962 503 17 144 960 79 80 314 134 1046 727 376 1074 478 54 408 344 340 726 745 310 627 320 6 855 164 84 388 387 39 434 799 868 1007 692 154 208 345 138 1023 904 296 1107 58 110 880 665 128 1097 104 564 1097 5 475 858 570 440 722 991 357 803 248 267 598 29 932 969 978 773 …
Output: 1882

Example 3:

Input: 796 3857 1 796 6 660 464 453 544 258 280 574 532 152 524 284 196 210 158 174 531 675 71 263 487 659 694 680 51 297 988 234 374 507 75 332 303 6 161 955 152 302 874 531 716 810 597 618 689 398 607 746 478 492 596 144 716 83 65 279 598 399 751 928 327 434 802 56 700 86 62 254 239 301 392 34 230 397 474 205 415 420 603 772 130 428 456 114 413 616 841 366 702 298 273 301 438 523 725 302 188 745 287 280 719 11 385 690 858 263 515 362 38 722 990 478 593 139 191 641 785 48 417 215 162 172 743 29 367 570 86 686 454 130 794 331 312 361 514 267 501 458 443 495 864 226 739 197 200 302 493 21 512 928 137 776 713 174 328 613 333 680 175 612 636 895 260 685 821 405 609 921 517 685 515 346 513 586 121 227 748 711 712 626 436 637 535 195 441 75 155 757 888 722 777 60 415 418 952 290 764 452 196 334 312 37…
Output: 488

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.