Skip to content

Instantly share code, notes, and snippets.

@chenminhua
Created October 18, 2019 03:53
Show Gist options
  • Save chenminhua/eb4a2b18f3fc95dbe6daa142d4ca1676 to your computer and use it in GitHub Desktop.
Save chenminhua/eb4a2b18f3fc95dbe6daa142d4ca1676 to your computer and use it in GitHub Desktop.
int find(int x)
{
if(x!=fa[x])
fa[x]=find(fa[x]);
return fa[x];
}
void union(int x,int y)
{
int a=find(x),b=find(y);
if(a!=b)
fa[b]=a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment