Skip to content

Instantly share code, notes, and snippets.

@saadtaame
Created August 31, 2016 13:22
int Find( int x ) {
int r = x;
/* Find root */
while(uf[r] >= 0)
r = uf[r];
/* Compress */
int t;
while(uf[x] >= 0) {
t = uf[x];
uf[x] = r;
x = t;
}
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment