1
0
Fork 0

Update graph/hld.cc

Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
subcrip 2024-09-14 20:24:44 +08:00
parent 72fa16acd0
commit 58e96d0164
1 changed files with 3 additions and 1 deletions

View File

@ -68,9 +68,10 @@ struct HLD {
swap(u, v);
}
tr.range_apply(info[info[u].head].dfn, info[u].dfn, t);
u = info[info[u].head].father;
}
if (info[u].depth < info[v].depth) swap(u, v);
tr.range_apply(info[v].dfn, info[u].dfn);
tr.range_apply(info[v].dfn, info[u].dfn, t);
}
Info path_query(int u, int v) {
@ -80,6 +81,7 @@ struct HLD {
swap(u, v);
}
res = res + tr.range_query(info[info[u].head].dfn, info[u].dfn);
u = info[info[u].head].father;
}
if (info[u].depth < info[v].depth) swap(u, v);
res = res + tr.range_query(info[v].dfn, info[u].dfn);