blob: d42800d6eba3d3dd52c43249523b8766e9ce3dd9 (
plain)
1
2
3
4
5
6
7
8
9
|
ranges::sort(edges, less{});
vector<Edge> mst;
ll cost = 0;
for (Edge& e : edges) {
if (findSet(e.from) != findSet(e.to)) {
unionSets(e.from, e.to);
mst.push_back(e);
cost += e.cost;
}}
|