Created
October 18, 2019 03:53
-
-
Save chenminhua/eb4a2b18f3fc95dbe6daa142d4ca1676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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