#4122. C++-GESP 2025-09认证八级-编程题02(最小生成树)

C++-GESP 2025-09认证八级-编程题02(最小生成树)

Background

Description

image image image

Format

Input

Output

Samples

5 5
1 2 4
2 3 3
3 4 1
2 5 2
3 1 8
14
15
-1
-1
10
6 10
1 2 6
2 3 3
3 1 4
3 4 5
4 5 8
5 6 2
6 4 1
3 2 4
5 4 4
3 3 6
15
16
17
-1
15
17
18
15
15
15

Limitation