diff options
Diffstat (limited to 'Data Structures/union-find_disjoint_set.cpp')
-rw-r--r-- | Data Structures/union-find_disjoint_set.cpp | 6 |
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 +}; |