CT61480

Teal corridors Cable Plan

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the maple sugarbush of Saprun pays by the answer, and Gita intends to earn it. First: the full register of corridors. 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 <= 1124; 0 <= m <= 3372; 0 <= w <= 1000000.

Example 1:

Input: 642 1547 125 163 283357 442 633 362612 240 278 659613 55 272 269196 188 620 352259 10 37 206788 393 567 235568 393 500 250298 411 608 442122 203 323 209376 501 559 952485 151 228 723503 518 553 498419 548 607 119106 1 170 801102 148 306 272770 490 538 607128 4 452 431389 199 274 576243 227 412 33410 66 85 352501 366 551 800320 240 317 624776 462 476 740004 374 512 905978 34 340 593406 193 642 723622 23 490 645662 137 462 993657 226 408 77843 24 631 537970 213 615 611137 244 299 632848 89 350 88580 2 254 822716 383 624 745816 121 630 684052 138 578 95419 311 439 798068 370 420 449095 87 505 883133 28 274 331294 125 356 310327 312 360 831153 107 620 920045 211 640 6601 16 315 661076 70 155 879741 292 578 562488 10 144 138066 6 601 764260 10 372 119473 517 547 932098 28 415 593443 99 380 2662…
Output: 152550176

Example 2:

Input: 581 900 270 330 550202 82 498 73888 270 562 889604 414 419 788914 3 204 876297 353 400 850079 280 310 363045 36 522 288277 51 576 818171 10 343 126848 83 378 25713 42 427 205571 57 507 73093 394 406 271720 275 565 61760 198 385 172385 284 504 182565 11 425 900975 142 225 231953 215 341 408317 319 384 244808 73 540 552065 83 373 943820 132 169 323535 187 402 806469 274 514 253751 121 149 493403 23 564 77644 106 288 868007 3 383 246781 269 504 515434 268 379 319442 201 549 63224 331 445 182418 356 475 983202 5 55 23142 321 389 683439 167 269 780481 54 243 591482 312 479 568065 42 208 498490 357 405 159225 394 578 504690 110 466 386703 310 521 894650 141 193 654713 201 429 768434 455 545 368240 440 454 93459 62 352 491434 245 544 247378 82 280 50217 132 272 105517 160 453 991888 49 256 387270…
Output: -1

Example 3:

Input: 448 1136 327 346 712430 57 341 616530 166 283 184030 247 279 221209 102 244 664963 78 394 56368 289 418 527959 126 320 327322 17 177 424171 261 326 846178 46 280 488051 73 177 439153 68 228 669830 44 160 183843 354 404 307059 117 235 450005 103 215 936930 127 430 447888 53 427 508204 132 345 352936 109 375 12570 272 304 125054 324 395 334702 35 404 461718 166 448 215939 166 252 88606 352 392 278885 39 56 9975 52 411 195751 277 308 62260 96 270 656401 199 275 353246 84 298 46744 350 365 761836 9 411 757781 124 339 121257 173 288 434175 136 210 835865 274 364 535667 117 422 445456 162 172 852662 120 200 289322 88 404 541760 75 117 18487 43 324 334107 116 230 971097 192 417 443726 29 260 352055 336 342 555227 244 347 102266 168 401 577937 352 428 459450 260 328 139710 40 348 327514 52 86 5651…
Output: 108824475

Constraints:

1 <= n <= 1124; 0 <= m <= 3372; 0 <= w <= 1000000.

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