跳到正文

个人记录

一道数据结构神提

黑部奈叶香约 2 分钟
原文
文章信息与版本

文章信息

发布
2022年11月20日
收录
2025年12月12日
更新
2026年9月4日
篇幅
约 2 分钟

版本

  1. v1当前

之前那玩意咕咕咕了。

给定一个序列,支持两种操作:单点修改,单点查询。

Solution 1

这个不是可持久化数组板子?

O(mlog⁡n)\mathcal{O}(m\log{n})。

Solution 2

带修莫队。

O(mn)\mathcal{O}(m\sqrt{n})。

Solution 3

线段树。

O(mlog⁡n)\mathcal{O}(m\log{n})。

Solution 4

LCT。

O(mlog⁡n)\mathcal{O}(m\log{n})。

Solution 5

Dynamic rankings.

O(mlog⁡n)\mathcal{O}(m\log{n})。

Solution 6

整体二分。

O(mlog⁡2n)\mathcal{O}(m\log^2n)。

Solution 7

BIT。

O(mlog⁡n)\mathcal{O}(m\log{n})。

Solution 8

分块入门。

O(mn)\mathcal{O}(m\sqrt{n})。

Solution 9

树剖

O(mlog⁡2n)\mathcal{O}(m\log^2n)。

Solution 10

暴力修改。

O(m+n)\mathcal{O}(m+n)。

Solution 11

考虑对原序列前缀和,于是可以做到 O(1)\mathcal{O}(1) 查询前缀和。

那么 an=sumn−sumn−1=O(1)−O(1)=O(0)a_n=sum_n-sum_{n-1}=\mathcal{O}(1)-\mathcal{O}(1)=\mathcal{O}(0)!

修改操作在差分数组上进行,用上述方法同理,不详述。

所以总时间复杂度为 O(0)\mathcal{O}(0)。

Solution 12

模拟退火即可。

Solution 13

此题无人通过。

Solution 14

用宇宙射线修改数据,把询问次数修改为没有,然后交空函数代码。

原文
存档评论2 条抓取于