Skip to content

Commit

Permalink
Update bts-hotcold.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
SansPapyrus683 authored May 5, 2024
1 parent 0710999 commit deaad3a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions solutions/platinum/bts-hotcold.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ class Tree {
tout[u] = timer - 1;
}

void update(int u, int v, int initial, int change) {
diff[u][0] += initial;
diff[u][1] += change;
if (change > 0) {
diff[v][0] -= initial + (depth[u] - depth[v]);
} else {
diff[v][0] -= initial - (depth[u] - depth[v]);
}
diff[v][1] -= change;
}

void dfs(int u, int p) {
for (int v : adj[u]) {
if (v == p) { continue; }
Expand Down Expand Up @@ -121,17 +132,6 @@ class Tree {
return depth[u] + depth[v] - 2 * depth[anc];
}

void update(int u, int v, int initial, int change) {
diff[u][0] += initial;
diff[u][1] += change;
if (change > 0) {
diff[v][0] -= initial + (depth[u] - depth[v]);
} else {
diff[v][0] -= initial - (depth[u] - depth[v]);
}
diff[v][1] -= change;
}

void query(int a, int b, int t) {
int anc = lca(a, b);
if (anc == t || !is_ancestor(anc, t)) {
Expand Down

0 comments on commit deaad3a

Please sign in to comment.