//union-find set: the vector/array contains the parent of each node int find(vector & C, int x){return (C[x]==x) ? x : C[x]=find(C, C[x]);} //C++ int find(int x){return (C[x]==x)?x:C[x]=find(C[x]);} //C