版本比较
线段树套树状数组套值域分块套块状链表
正文
增加 4 行删除 4 行
150 行未改动全部展开15115215315415515515615715815966 行未改动2262272282292302302312322332347 行未改动242243244245246246247248249250131 行未改动全部展开382383384385386386387388150 行未改动全部展开 if (opt == 'Q') read(k), k ^= last, writeln(last = kth(l - 1, r - 1, k)); else if (opt == 'M') modify(l - 1, r); else if (opt == 'I') insert(l - 1, r); } FastIO::flush();} }```::::
树状数组套可持久化权值线段树可以降到 $\log^2$,或许能过。但我的思路想到值域分块去了。66 行未改动 int p = 0, n = bit.size(); for (int i = lg(n); i >= 0; i--) { int x = p + (1 << i); if (x < n && k >= bit[x]) k -= bit[x], p = x; } } return {p, k}; }} idx;
7 行未改动 for (; x <= NB; x += lowbit(x)) a[x] += c; } int ask(int x) const { int res = 0; for (; x >= 1; x -= lowbit(x)) res += a[x]; for (; x >= 1; x -= lowbit(x)) res += a[x]; return res; } } bit[4 * (N + M) / L]; void build(int l = 1, int r = blocks.size(), int rt = 1) {131 行未改动全部展开 if (opt == 'Q') read(k), writeln(last = kth(l, r, k ^ last)); else if (opt == 'M') modify(l, r); else if (opt == 'I') insert(l, r); } FastIO::flush();} }```::::