Skip to content

Commit

Permalink
another golf
Browse files Browse the repository at this point in the history
  • Loading branch information
lrvideckis committed Dec 17, 2024
1 parent 9bfc7ab commit f862976
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions content/graph/HLD.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ template <bool VALS_EDGES> struct HLD {
}
}
template <class B> void process(int u, int v, B op) {
for (; rt[u] != rt[v]; v = par[rt[v]]) {
for (;; v = par[rt[v]]) {
if (pos[u] > pos[v]) swap(u, v);
if (rt[u] == rt[v]) break;
op(pos[rt[v]], pos[v] + 1);
}
if (pos[u] > pos[v]) swap(u, v);
op(pos[u] + VALS_EDGES, pos[v] + 1);
}
void modifyPath(int u, int v, int val) {
Expand Down

0 comments on commit f862976

Please sign in to comment.