#include #include #include using namespace std; typedef pair> Edge; // {weight, {vertex1, vertex2}} class DisjointSetUnion { public: vector parent, rank; DisjointSetUnion(int n) { parent.resize(n); rank.resize(n, 0); for (int i = 0; i < n; ++i) { parent[i] = i; } } int find(int x) { if (x != parent[x]) { parent[x] = find(parent[x]); } return parent[x]; } void unite(int x, int y) { int rootX =