CT63251

The Pearl corridors of Ysolde

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Ysolde inherited the print shop at the cedar groves of Balmcrest along with its curious bookkeeping system for corridors. Time to make sense of it. 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 <= 1417; 0 <= m <= 4251; 0 <= w <= 1000000.

Example 1:

Input: 446 1599 26 59 439026 21 146 162234 276 440 606363 275 436 771789 107 157 653879 258 395 372288 150 250 11246 17 49 895426 82 315 440701 240 300 803986 63 297 794566 54 335 653726 53 286 665176 238 358 581427 236 359 373393 3 383 202882 115 206 782366 213 352 595956 233 294 862908 125 157 772636 86 206 53837 311 338 284343 22 284 321465 63 240 938544 8 16 471510 156 398 466657 41 125 426957 10 312 640742 208 307 966550 290 376 871521 280 324 469107 132 208 909217 23 97 281424 328 439 699697 218 405 470527 71 281 3754 99 255 443689 129 365 816421 37 273 139557 274 425 826351 45 355 395013 227 229 679164 202 397 722169 25 106 862694 175 198 664782 57 134 576573 20 275 842761 254 436 865100 59 176 204390 292 298 914257 45 428 812096 310 347 324363 119 248 790383 172 220 218074 138 423 443410 …
Output: 78607624

Example 2:

Input: 249 2654 200 209 117323 22 50 26159 40 231 711945 54 146 611500 64 173 13883 15 80 455585 141 200 568650 48 70 500654 51 91 753109 68 178 981853 83 137 501840 31 64 207178 131 200 462937 172 243 789240 19 36 976935 136 158 594158 74 84 540259 48 202 891772 63 145 330907 150 211 676861 86 177 930618 92 135 242689 76 192 484766 30 200 41367 17 57 300857 104 176 789695 185 232 188634 45 107 722965 55 106 733863 12 17 990861 43 204 770281 37 101 556931 145 246 78489 85 151 13697 6 133 131488 90 177 485281 2 193 265194 18 163 729228 33 209 759629 50 64 120850 170 174 736865 46 189 181990 142 187 753732 21 193 474286 198 199 390448 136 223 881005 75 220 620310 29 166 194088 185 197 316010 16 44 223438 124 135 501549 68 162 98340 133 184 717686 198 249 955134 83 194 816111 118 180 851774 13 70 20…
Output: 12513663

Example 3:

Input: 701 3738 559 613 408611 97 433 218321 277 299 405587 56 239 621505 276 445 179248 324 394 78701 172 670 983774 4 91 846127 176 382 153951 48 313 842711 81 435 254817 187 379 943982 383 429 62590 134 459 57665 462 516 399129 271 563 109741 259 599 952563 286 656 163944 242 477 278324 323 401 302342 433 600 94906 185 543 952662 363 634 586317 250 537 556098 214 553 123865 345 485 539160 126 389 832734 497 633 900292 223 616 749719 479 592 798936 451 522 365505 177 554 445031 188 647 966908 202 217 868994 207 587 487746 173 689 57559 483 658 765409 489 567 740533 218 636 446834 48 611 60804 7 256 232792 446 507 633740 202 543 196493 213 515 971903 293 352 563560 91 108 165571 215 691 163466 146 343 384673 48 688 520438 85 103 121795 9 487 775875 308 632 849096 120 263 513302 370 559 970032 45…
Output: 80267086

Constraints:

1 <= n <= 1417; 0 <= m <= 4251; 0 <= w <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The Pearl corridors of Ysolde - MEDIUM Coding Problem | CodeTikki