Skip to content

Commit bcd04c6

Browse files
committed
one last optimization
1 parent 45d173f commit bcd04c6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

library/dsu/dsu_weighted.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ struct dsu_weighted {
2323
}
2424
bool join(int u, int v, ll w) {
2525
int x = f(u), y = f(v);
26-
w += d[u] - d[v];
2726
if (x == y) return 0;
27+
w += d[u] - d[v];
2828
if (p[x] > p[y]) swap(x, y), w = -w;
2929
return p[x] += p[y], p[y] = x, d[y] = w, 1;
3030
}

0 commit comments

Comments
 (0)