From 54aa7ffc70c05c662373c401d95f2cde6c321067 Mon Sep 17 00:00:00 2001 From: hanyixuanten Date: Thu, 29 Oct 2026 05:58:29 +0000 Subject: [PATCH] new file: solutions/P3384.md --- solutions/P3384.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 solutions/P3384.md diff --git a/solutions/P3384.md b/solutions/P3384.md new file mode 100644 index 0000000..94cef78 --- /dev/null +++ b/solutions/P3384.md @@ -0,0 +1,16 @@ +# P3384 【模板】重链剖分 / 树链剖分 题解 + +重链剖分模板。习惯用线段树(也可以双 BIT)。 + +其中: + +- [L13-48](../P3384.cpp#L13-49) 为维护区间和的线段树。 +- [L49-59](../P3384.cpp#L49-60) 为 dfs1,处理 $dep, cnt, fa, son$。 +- [L60-71](../P3384.cpp#L60-72) 为 dfs2,处理 $dfn, top$。 +- [L72-80](../P3384.cpp#L72-81) 为路径加,上跳即可。 +- [L81-90](../P3384.cpp#L81-91) 为路径查询,与修改是类似的。 +- [L91-96](../P3384.cpp#L91-97) 为子树修改与查询,由于子树的 $dfn$ 序列是连续的,直接在线段树上修改即可。 + +接下来建议用树链剖分解决一些[简单题](https://www.luogu.com.cn/problem/list?type=luogu&page=1&tag=228&orderBy=difficulty&order=asc)。 + +[code](../P3384.cpp)