aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2020-09-05 17:17:25 -0500
committerAnthony Wang2020-09-05 17:17:25 -0500
commita9bc65e2c871db1d786f718f6e92ad3921006fdb (patch)
tree67ee72e35be1c6749899a47ccc0a89d1d0fdeb29
parent9f56b8f9fb6295ae3c3a219b5356b359a2d414a0 (diff)
Update union-find_disjoint_set.cpp
-rw-r--r--Data Structures/union-find_disjoint_set.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Data Structures/union-find_disjoint_set.cpp b/Data Structures/union-find_disjoint_set.cpp
index b47139f..0ffee07 100644
--- a/Data Structures/union-find_disjoint_set.cpp
+++ b/Data Structures/union-find_disjoint_set.cpp
@@ -2,9 +2,9 @@ class UFDS {
private: vector<int> p, rank;
public:
UFDS(int N) {
- p.assign(N + 1, 0);
+ p.assign(N+1, 0);
for (int i = 0; i <= N; i++) p[i] = i;
- rank.assign(N + 1, 0);
+ rank.assign(N+1, 0);
}
int find_set(int i) { return (p[i] == i) ? i : (p[i] = find_set(p[i])); }
bool same_set(int i, int j) { return find_set(i) == find_set(j); }
@@ -14,4 +14,4 @@ public:
rank[x] > rank[y] ? p[y] = x : p[x] = y;
if (rank[x] == rank[y]) rank[y]++;
}
-}; \ No newline at end of file
+};