Someone
public cpp v1 · immutablelong long find(int x,int y){ long long res=0; int l1=level[x]; int l2=level[y]; int p1=x,p2=y; if(l1<l2){ while(l2>l1){ p2=graph[p2]; l2=level[p2]; } } else if(l1>l2){ while(l1>l2){ p1=graph[p1]; l1=level[p1]; } } while(p1!=p2){ p2=graph[p2]; p1=graph[p1]; } return p1;}