1 int pa[maxn]; 2 for(int i = 0; i < maxn; i++) pa[i] = i; 3 int findpa(int x) {return pa[x] != x ? findpa(pa[x]) : x;}