We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a72baa0 commit 357c621Copy full SHA for 357c621
copypasta/union_find.go
@@ -150,6 +150,7 @@ func unionFind(n int) {
150
// 并查集 - 维护点权
151
// 维护的可以是集合的大小、最值、XOR、GCD 等
152
// https://codeforces.com/edu/course/2/lesson/7/1/practice/contest/289390/problem/B
153
+// https://codeforces.com/problemset/problem/1609/D
154
// LC 周赛 203D https://leetcode-cn.com/contest/weekly-contest-203/problems/find-latest-group-of-size-m/
155
func unionFindVertexWeight(n int) {
156
var fa, sz []int
@@ -173,6 +174,7 @@ func unionFindVertexWeight(n int) {
173
174
from, to = find(from), find(to)
175
if from != to {
176
sz[to] += sz[from]
177
+ //sz[from] = 0 // 有些题目需要保证总 sz 和不变(如 CF1609D)
178
fa[from] = to
179
}
180
0 commit comments