#P2619. [国家集训队] Tree I
[国家集训队] Tree I
Description
You are given an undirected, weighted, connected graph. Each edge is colored black or white. Find a minimum-total-weight spanning tree that contains exactly white edges.
It is guaranteed that a solution exists.
Input Format
The first line contains , the numbers of vertices, edges, and the required number of white edges.
Then follow lines. Each line contains , denoting the endpoints (vertices are numbered from ), the edge weight, and the color ( for white, for black).
Output Format
Output one line: the total weight of the required spanning tree.
2 2 1
0 1 1 1
0 1 2 0
2
Hint
Constraints:
- For of the testdata, .
- For another of the testdata, .
- For of the testdata, .
- All edge weights are positive integers in .
By WJMZBMR.
Translated by ChatGPT 5
京公网安备 11011102002149号