CT64568

The Cable Plan of the Whispering corridors

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the spice bazaar of Saffronia opens only for a perfect tally of corridors. Cyrus means to find out. 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 <= 1212; 0 <= m <= 3636; 0 <= w <= 1000000.

Example 1:

Input: 251 2032 156 158 373098 99 129 628979 54 135 398338 153 159 827787 65 108 131596 65 146 288959 69 117 356652 154 204 64816 83 84 784056 93 96 896196 45 212 309615 67 70 664705 22 169 949852 38 138 268353 130 243 741675 128 199 365293 63 205 332128 35 132 411894 119 192 380171 60 101 611873 192 245 764264 75 136 678500 114 244 387991 152 241 788414 57 177 467027 104 105 80662 48 250 127130 34 222 257092 103 159 788788 67 235 775980 52 161 663450 119 216 871335 64 242 359440 23 183 274109 137 190 345249 28 38 798909 161 212 606683 114 168 550167 58 66 973239 14 109 337044 13 91 225789 17 105 62292 128 135 198012 47 78 444872 112 189 612461 111 153 377886 40 76 749970 92 187 614472 83 162 261767 18 51 345015 35 71 379615 209 230 694252 181 200 957305 82 247 260352 2 35 224332 166 178 631032 1…
Output: 17164527

Example 2:

Input: 486 2074 381 437 110695 119 285 417542 81 195 371756 221 351 447748 283 420 623000 4 301 295454 189 440 233809 222 441 733558 49 327 925573 39 443 978100 232 440 250659 103 256 177342 66 345 7305 12 298 888208 120 147 409004 105 222 773774 83 420 119987 77 320 992597 24 195 27827 443 474 899699 237 370 26644 19 320 873243 334 455 522524 414 453 131719 347 354 610016 73 387 302703 77 418 615360 262 413 909525 280 467 384129 268 408 168523 153 342 155274 106 411 146314 120 261 637268 162 413 933791 304 436 414861 236 473 20497 132 273 11404 207 412 320748 11 306 347615 167 486 233959 123 315 366875 34 442 656668 192 253 244242 374 475 633063 122 146 68890 193 207 921024 27 328 643294 312 362 371214 93 376 35905 63 225 182451 87 291 174272 135 431 686977 98 449 633756 259 312 160899 86 303 75…
Output: 67669682

Example 3:

Input: 501 2802 312 484 212878 110 127 566542 153 163 267012 75 302 907907 50 241 15601 60 80 872829 246 344 79487 173 283 56438 274 310 89802 16 258 53974 360 411 142858 411 459 404946 270 480 923014 82 333 215680 259 272 827047 229 435 707125 102 419 863172 342 350 244074 67 287 151709 1 408 508162 162 346 611922 44 464 419817 212 213 258871 18 435 218732 44 86 457594 2 414 882517 300 388 825984 66 70 916811 368 445 212543 306 490 170539 60 106 5556 264 296 467401 147 161 513048 94 479 185204 99 220 518432 7 313 130593 78 274 428012 9 340 568853 71 209 186769 386 410 384107 44 67 47840 224 308 771483 70 476 404293 298 405 571289 176 370 797323 251 340 678150 346 499 135358 189 470 480319 72 340 584589 225 311 224045 97 232 617529 287 390 319218 72 185 342513 132 407 807986 141 445 485040 22 312…
Output: 51511212

Constraints:

1 <= n <= 1212; 0 <= m <= 3636; 0 <= w <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The Cable Plan of the Whispering corridors - MEDIUM Coding Problem | CodeTikki