CT60035

The Sable Cable Plan

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Caravans arrive at the savanna camp of Amberplain with crates of tunnels, and Ulmar the scribe must account for every last one. Task: Print the minimum total weight of a spanning tree, or -1 if the graph is not connected. Input format: First line: n and m. Next m lines: u v w. Output format: Print the MST weight or -1. Constraints: 1 <= n <= 912; 0 <= m <= 2736; 0 <= w <= 1000000.

Example 1:

Input: 602 1808 243 370 177476 239 487 352723 33 221 891976 47 245 372407 593 597 26262 259 307 376586 23 456 650642 312 555 720174 133 594 452866 188 538 431893 138 520 496591 57 268 322009 315 571 487537 209 257 641684 279 383 676098 291 561 949702 56 115 249205 155 317 962541 46 587 328656 110 204 536223 128 136 674245 36 77 710221 322 529 754603 28 522 274055 410 574 620505 336 392 364325 340 343 344593 70 326 749302 91 267 930489 360 422 550103 436 537 223019 300 340 79098 185 276 555032 126 525 400786 27 269 469851 252 381 824823 578 585 992166 241 344 209682 16 251 6399 220 486 607445 118 153 365537 396 595 956902 27 89 358645 365 527 220157 24 523 824772 193 212 631434 293 583 945174 37 272 50381 46 290 967036 162 475 163210 34 476 494242 141 333 402045 127 382 933147 328 546 251159 190 2…
Output: 125758651

Example 2:

Input: 28 378 2 28 123293 8 16 128441 3 18 748877 22 26 422583 6 19 925409 14 26 411756 19 26 68274 7 12 884655 14 18 847061 6 14 723183 8 12 490081 4 25 703654 3 8 112775 4 10 859040 5 21 316516 11 27 228114 14 17 482524 1 16 110323 13 25 237181 10 12 916713 22 27 718768 2 25 877385 12 28 144764 4 16 986494 23 26 370182 6 12 258060 13 23 599526 21 26 928657 22 24 915634 17 25 923628 11 19 279531 8 26 825397 18 23 554191 5 14 897436 5 15 52573 4 7 282702 16 26 385424 9 24 849184 24 27 475289 17 24 970834 6 26 511904 4 6 19033 9 19 422760 9 13 293898 6 25 435388 10 21 538724 2 22 366839 5 11 794766 23 24 406839 14 27 163557 13 20 33808 16 22 300125 26 28 972325 7 13 767751 5 12 296780 3 5 983055 2 19 121809 20 25 16754 8 21 759065 5 6 869385 7 10 807949 1 18 763461 10 19 963335 16 28 457740 8 10 8…
Output: 933954

Example 3:

Input: 500 2353 320 399 920276 405 411 372489 69 252 581965 99 149 448988 102 245 631072 217 458 912793 344 363 512082 164 444 149541 130 172 850597 48 456 126216 47 285 278850 17 338 431071 246 257 460694 239 247 363786 325 329 3491 197 398 406661 113 335 739553 119 386 226089 179 360 223433 147 431 389340 115 285 90809 64 358 497240 226 340 683824 400 412 211127 59 262 950785 23 203 206127 16 110 444843 390 454 771777 256 497 685288 448 497 593387 164 220 378998 36 344 826670 99 297 963308 147 220 608992 70 404 634943 235 435 270264 4 189 409171 163 249 855125 363 475 745239 150 297 957943 125 141 977477 52 425 975819 424 478 85238 224 320 191943 53 219 154200 251 365 315695 74 357 920529 216 379 901798 54 118 987641 19 389 637210 315 457 9064 329 442 686899 245 405 81999 209 464 731235 102 196…
Output: 58506165

Constraints:

1 <= n <= 912; 0 <= m <= 2736; 0 <= w <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The Sable Cable Plan - MEDIUM Coding Problem | CodeTikki