#includetemplate class disj_set {public: disj_set(){ for (int i=0; i rank[y]) father[fy] = fx; else { father[fx] = fy; if (rank[fx] == rank[fy]) rank[fy]++; } }private: int father[size]; int rank[size];};int main() { disj_set<5> s1; s1.find_set(0); s1.find_set(1); s1.find_set(2); s1.find_set(3); s1.find_set(4); s1.union_set(1,3); s1.find_set(2); s1.find_set(4); s1.union_set(0,1); s1.union_set(1,2); s1.union_set(2,3); s1.union_set(3,4);}