Time limit
1s
Memory limit
128 MB
You are given an undirected weighted graph. Among all subgraphs that connect every vertex, find a tree whose total edge weight is as small as possible.
Such a tree is called a minimum spanning tree.
The first line contains the number of vertices V and the number of edges E.
1 <= V <= 10,0001 <= E <= 100,000Each of the next E lines contains three integers A, B, and C, describing one edge. It means that vertex A and vertex B are connected by an edge with weight C.
1 to V.C may be negative, and |C| <= 1,000,000.Print the total weight of the minimum spanning tree on one line.