Skip to content

Commit f862976

Browse files
committed
another golf
1 parent 9bfc7ab commit f862976

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/graph/HLD.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ template <bool VALS_EDGES> struct HLD {
4242
}
4343
}
4444
template <class B> void process(int u, int v, B op) {
45-
for (; rt[u] != rt[v]; v = par[rt[v]]) {
45+
for (;; v = par[rt[v]]) {
4646
if (pos[u] > pos[v]) swap(u, v);
47+
if (rt[u] == rt[v]) break;
4748
op(pos[rt[v]], pos[v] + 1);
4849
}
49-
if (pos[u] > pos[v]) swap(u, v);
5050
op(pos[u] + VALS_EDGES, pos[v] + 1);
5151
}
5252
void modifyPath(int u, int v, int val) {

0 commit comments

Comments
 (0)