Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(segment-tree-offline.md): fix typo #5595

Merged
merged 7 commits into from
May 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/topic/segment-tree-offline.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ author: xiezheyuan

假如你需要维护一些信息,这些信息会在某一个时间段内出现,要求在离线的前提下回答某一个时刻的信息并,则可以考虑使用线段树分治的技巧。

实际上线段树分治常用于不带删的数据结构转成可以带删的数据结构,抑或是对于某一个属性的信息分别计算。
实际上线段树分治常有以下用途:

1. 用原本不支持删除的数据结构来模拟删除操作。如朴素的并查集无法高效支持删边操作,这时候我们可以用线段树分治来处理。
Tiphereth-A marked this conversation as resolved.
Show resolved Hide resolved
2. 不同属性的数据分别计算。如需要求出除了某一种颜色外,其他颜色数据的答案,这时候我们也可以用线段树分治来处理。

如果大家现在不明白没有关系,这两种用途我们都会在例题中阐述。

## 过程

Expand Down Expand Up @@ -40,7 +45,7 @@ author: xiezheyuan
Object ans[N]; // 答案

void solve(int i, int l, int r) {
auto lvl = sta.size(); // 记录一下应当撤销到底几个
auto lvl = sta.size(); // 记录一下应当撤销到第几个
for (Object x : tree[i]) sta.push(now), now = Merge(now, x); // 合并信息
if (l == r)
ans[i] = now; // 记录一下答案
Expand Down