Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- rBool() <= getRand() & 1024
- */
- int dsu_get (int v) {
- if (v == p[v]) return v;
- else return p[v] = dsu_get(p[v]);
- }
- void dsu_unite (int a, int b) {
- a = dsu_get (a); b = dsu_get (b);
- if (a != b) {
- if (rBool() & 1)
- swap(a, b);
- p[a] = b;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement