Advertisement
maiden18

[SOLID] DSU

Feb 20th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1. int Par[MAX];
  2.  
  3. int Find(int x)
  4. {
  5.     if (x==Par[x]) return x;
  6.     return Par[x]=Find(Par[x]);
  7. }
  8.  
  9. void Union(int x, int y)
  10. {
  11.     x=Find(x);
  12.     y=Find(y);
  13.     if(x!=y) Par[x]=y;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement