版本比较
线段树学习笔记
正文
增加 23 行删除 3 行
38 行未改动394041424343444546474849505152535354555657585960616263646566676869707123 行未改动959697989910010110210312 行未改动11611711811912012112212312412512 行未改动13813914014113114214314414514614714814915031 行未改动1821831841851861871881891901911929 行未改动20220320420520620738 行未改动- [AT_abc341_e [ABC341E] Alternating String](https://www.luogu.com.cn/problem/AT_abc341_e)- [P5522 [yLOI2019] 棠梨煎雪](https://www.luogu.com.cn/problem/P5522)- [AT_abc343_f [ABC343F] Second Largest Query](https://www.luogu.com.cn/problem/AT_abc343_f)- [CF482B Interesting Array](https://www.luogu.com.cn/problem/CF482B)(构造)- (未写) P4513 小白逛公园- [P4513 小白逛公园](https://www.luogu.com.cn/problem/P4513)- (未写) P1471 方差- (未写) P5142 区间方差- (未写) P2572 [SCOI2010] 序列操作
#### 2. 维护有关区间的函数值
- [P6477 [NOI Online #2 提高组] 子序列问题](https://www.luogu.com.cn/problem/P6477)- (其他题暂时没写)
#### 3. 诈骗题合集#### 3. 二分答案,转为 0/1 序列操作
- [P2824 [HEOI2016/TJOI2016] 排序](https://www.luogu.com.cn/problem/P2824)
#### 4. 诈骗题合集
- [P4145 上帝造题的七分钟 2 / 花神游历各国](https://www.luogu.com.cn/problem/P4145)- [CF438D The Child and Sequence](https://www.luogu.com.cn/problem/CF438D)- [AT_abc256_h [ABC256Ex] I like Query Problem](https://www.luogu.com.cn/problem/AT_abc256_h)- (还有吗)
#### 5. 技巧题
- [CF242E XOR on Segment](https://www.luogu.com.cn/problem/CF242E)(各位分开)
### 三、线段树优化 dp
- [AT_abc339_e [ABC339E] Smooth Subsequence](https://www.luogu.com.cn/problem/AT_abc339_e) / [AT_abl_d Flat Subsequence](https://www.luogu.com.cn/problem/AT_abl_d)- [AT_abc353_g [ABC353G] Merchant Takahashi](https://www.luogu.com.cn/problem/AT_abc353_g)23 行未改动- [P3833 [SHOI2012] 魔法树](https://www.luogu.com.cn/problem/P3833)- [P4315 月下“毛景树”](https://www.luogu.com.cn/problem/P4315)- [P12075 [OOI 2025] Dreaming is not harmful](https://www.luogu.com.cn/problem/P12075)(思维题)- [P3979 遥远的国度](https://www.luogu.com.cn/problem/P3979)(倍增、换根)- [P4211 [LNOI2014] LCA](https://www.luogu.com.cn/problem/P4211)(离线,前缀和相减)- [P1505 [国家集训队] 旅游](https://www.luogu.com.cn/problem/P1505)- ...
### 五、线段树的经典运用12 行未改动通过离线+离散化+线段树二分,我们可以查询区间信息。
- [P4137 Rmq Problem / mex](https://www.luogu.com.cn/problem/P4137)- [P13514 [KOI 2025 #1] 干草堆](https://www.luogu.com.cn/problem/P13514)- [P3224 [HNOI2012] 永无乡](https://www.luogu.com.cn/problem/P3224)(线段树合并+线段树二分)- ...
#### 4. 线段树解决简化版三维偏序
- [AT_abc309_f [ABC309F] Box in Box](https://www.luogu.com.cn/problem/AT_abc309_f)12 行未改动(还没写过)
#### 2.线段树合并
(还没写过)- [P4556 【模板】线段树合并](https://www.luogu.com.cn/problem/P4556)(树上差分)- [CF600E Lomsat gelral](https://www.luogu.com.cn/problem/CF600E)(从叶向根合并)- [P9233 [蓝桥杯 2023 省 A] 颜色平衡树](https://www.luogu.com.cn/problem/P9233)(最大值 $\times$ 出现次数 $=$ 子树大小)- [P3224 [HNOI2012] 永无乡](https://www.luogu.com.cn/problem/P3224)(线段树合并+线段树二分)- ...
#### 3. 线段树分治
(还没写过)31 行未改动
#### 1. 线段树优化建图
- [P5025 [SNOI2017] 炸弹](https://www.luogu.com.cn/problem/P5025)(动态开点)- [CF786B Legacy](https://www.luogu.com.cn/problem/CF786B)- [P6348 [PA 2011] Journeys](https://www.luogu.com.cn/problem/P6348)(虚点)- [P9331 [JOIST 2023] 护照 / Passport](https://www.luogu.com.cn/problem/P9331)(建反图)- ...
#### 2. 李超线段树
9 行未改动
#### 5. 与其他数据结构的综合运用
- [P1848 [USACO12OPEN] Bookshelf G](https://www.luogu.com.cn/problem/P1848)(线段树+单调队列优化 DP)- [P4093 [HEOI2016/TJOI2016] 序列](https://www.luogu.com.cn/problem/P4093)(树状数组套动态开点线段树)- [P2605 [ZJOI2010] 基站选址](https://www.luogu.com.cn/problem/P2605)(BIT + $K$ 棵 SGT)