From 58e96d0164dee2386601f2676641c6eab499fed5 Mon Sep 17 00:00:00 2001 From: subcrip Date: Sat, 14 Sep 2024 20:24:44 +0800 Subject: [PATCH] Update graph/hld.cc Signed-off-by: subcrip --- graph/hld.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graph/hld.cc b/graph/hld.cc index fec48e6..0fcf377 100644 --- a/graph/hld.cc +++ b/graph/hld.cc @@ -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);