Skip to content

Commit

Permalink
fix splay bug; better window rmq;
Browse files Browse the repository at this point in the history
  • Loading branch information
old-yan committed Nov 24, 2024
1 parent 0af798a commit 4d155ec
Show file tree
Hide file tree
Showing 36 changed files with 1,221 additions and 550 deletions.
1 change: 1 addition & 0 deletions DS/AVL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
8. [寿命修改](https://ac.nowcoder.com/acm/problem/275139)
9. [数据结构](https://ac.nowcoder.com/acm/problem/276699)
10. [Dynamic Sequence Range Affine Range Sum](https://judge.yosupo.jp/problem/dynamic_sequence_range_affine_range_sum)(https://github.com/yosupo06/library-checker-problems/issues/242)
11. [Ordered Set](https://judge.yosupo.jp/problem/ordered_set)(https://github.com/yosupo06/library-checker-problems/issues/1243)


### 二、模板功能
Expand Down
2 changes: 2 additions & 0 deletions DS/AssignZkwTree.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

1. 声明 `value_type` 为值类型。

​ 在此情况下,由于没有幺元,所以要求在构造的时候必须赋初值。

​ 对于进行区间查询,且元素能够快速翻倍的场景,对幺半群的要求:

1. 声明 `value_type` 为值类型;
Expand Down
8 changes: 5 additions & 3 deletions DS/CatTree.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
​ 练习题目:

1. [3117. 划分数组得到最小的值之和](https://leetcode.cn/problems/minimum-sum-of-values-by-dividing-array/)
2. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
3. [P1890 gcd区间](https://www.luogu.com.cn/problem/P1890)
4. [P3865 【模板】ST 表](https://www.luogu.com.cn/problem/P3865)
2. [P1440 求m区间内的最小值](https://www.luogu.com.cn/problem/P1440)
3. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
4. [P1890 gcd区间](https://www.luogu.com.cn/problem/P1890)
5. [P2032 扫描](https://www.luogu.com.cn/problem/P2032)
6. [P3865 【模板】ST 表](https://www.luogu.com.cn/problem/P3865)

### 二、模板功能

Expand Down
4 changes: 3 additions & 1 deletion DS/CompressedTree.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
​ 练习题目:

1. [P1801 黑匣子](https://www.luogu.com.cn/problem/P1801)
2. [U311262 求区间后继](https://www.luogu.com.cn/problem/U311262)
2. [P3088 [USACO13NOV] Crowded Cows S](https://www.luogu.com.cn/problem/P3088)
3. [U311262 求区间后继](https://www.luogu.com.cn/problem/U311262)
4. [Point Set Range Composite (Large Array)](https://judge.yosupo.jp/problem/point_set_range_composite_large_array)(https://github.com/yosupo06/library-checker-problems/issues/828)

### 二、模板功能

Expand Down
5 changes: 3 additions & 2 deletions DS/Deque.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
​ 练习题目:

1. [B3656 【模板】双端队列 1](https://www.luogu.com.cn/problem/B3656)
2. [P8496 [NOI2022] 众数](https://www.luogu.com.cn/problem/P8496)
3. [Deque Operate All Composite](https://judge.yosupo.jp/problem/deque_operate_all_composite)(https://github.com/yosupo06/library-checker-problems/issues/815)
2. [P3088 [USACO13NOV] Crowded Cows S](https://www.luogu.com.cn/problem/P3088)
3. [P8496 [NOI2022] 众数](https://www.luogu.com.cn/problem/P8496)
4. [Deque Operate All Composite](https://judge.yosupo.jp/problem/deque_operate_all_composite)(https://github.com/yosupo06/library-checker-problems/issues/815)


### 二、模板功能
Expand Down
3 changes: 3 additions & 0 deletions DS/ErasableMonoPairHeap.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
​ 练习题目:

1. [3321. 计算子数组的 x-sum II](https://leetcode.cn/problems/find-x-sum-of-all-k-long-subarrays-ii)
2. [P1440 求m区间内的最小值](https://www.luogu.com.cn/problem/P1440)
3. [P2032 扫描](https://www.luogu.com.cn/problem/P2032)



### 二、模板功能
Expand Down
12 changes: 7 additions & 5 deletions DS/MaskRMQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
​ 练习题目:

1. [Check Corners](http://acm.hdu.edu.cn/showproblem.php?pid=2888)
2. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
3. [P3793 由乃救爷爷](https://www.luogu.com.cn/problem/P3793)
4. [P3865 【模板】ST 表](https://www.luogu.com.cn/problem/P3865)
5. [k - 路径(hard vension)](https://ac.nowcoder.com/acm/problem/279411)
6. [小红的树上路径查询(hard)](https://ac.nowcoder.com/acm/problem/281352)
2. [P1440 求m区间内的最小值](https://www.luogu.com.cn/problem/P1440)
3. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
4. [P2032 扫描](https://www.luogu.com.cn/problem/P2032)
5. [P3793 由乃救爷爷](https://www.luogu.com.cn/problem/P3793)
6. [P3865 【模板】ST 表](https://www.luogu.com.cn/problem/P3865)
7. [k - 路径(hard vension)](https://ac.nowcoder.com/acm/problem/279411)
8. [小红的树上路径查询(hard)](https://ac.nowcoder.com/acm/problem/281352)


### 二、模板功能
Expand Down
21 changes: 11 additions & 10 deletions DS/MonoAVL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
2. [P1503 鬼子进村](https://www.luogu.com.cn/problem/P1503)
3. [P1801 黑匣子](https://www.luogu.com.cn/problem/P1801)
4. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
5. [P3369 【模板】普通平衡树](https://www.luogu.com.cn/problem/P3369)
6. [P3391 【模板】文艺平衡树](https://www.luogu.com.cn/problem/P3391)
7. [P4036 [JSOI2008] 火星人](https://www.luogu.com.cn/problem/P4036)
8. [P4774 [NOI2018] 屠龙勇士](https://www.luogu.com.cn/problem/P4774)
9. [P6136 【模板】普通平衡树(数据加强版)](https://www.luogu.com.cn/problem/P6136)
10. [U361730 【模板】完全体·堆](https://www.luogu.com.cn/problem/U361730)
11. [翻转排序](https://ac.nowcoder.com/acm/problem/275173)
12. [旅途的终点](https://ac.nowcoder.com/acm/problem/275989)
13. [正义从不打背身](https://ac.nowcoder.com/acm/problem/277862)
14. [Range Reverse Range Sum](https://judge.yosupo.jp/problem/range_reverse_range_sum)(https://github.com/yosupo06/library-checker-problems/issues/538)
5. [P2032 扫描](https://www.luogu.com.cn/problem/P2032)
6. [P3369 【模板】普通平衡树](https://www.luogu.com.cn/problem/P3369)
7. [P3391 【模板】文艺平衡树](https://www.luogu.com.cn/problem/P3391)
8. [P4036 [JSOI2008] 火星人](https://www.luogu.com.cn/problem/P4036)
9. [P4774 [NOI2018] 屠龙勇士](https://www.luogu.com.cn/problem/P4774)
10. [P6136 【模板】普通平衡树(数据加强版)](https://www.luogu.com.cn/problem/P6136)
11. [U361730 【模板】完全体·堆](https://www.luogu.com.cn/problem/U361730)
12. [翻转排序](https://ac.nowcoder.com/acm/problem/275173)
13. [旅途的终点](https://ac.nowcoder.com/acm/problem/275989)
14. [正义从不打背身](https://ac.nowcoder.com/acm/problem/277862)
15. [Range Reverse Range Sum](https://judge.yosupo.jp/problem/range_reverse_range_sum)(https://github.com/yosupo06/library-checker-problems/issues/538)


### 二、模板功能
Expand Down
21 changes: 11 additions & 10 deletions DS/MonoSplay.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
2. [P1503 鬼子进村](https://www.luogu.com.cn/problem/P1503)
3. [P1801 黑匣子](https://www.luogu.com.cn/problem/P1801)
4. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
5. [P3369 【模板】普通平衡树](https://www.luogu.com.cn/problem/P3369)
6. [P3391 【模板】文艺平衡树](https://www.luogu.com.cn/problem/P3391)
7. [P4036 [JSOI2008] 火星人](https://www.luogu.com.cn/problem/P4036)
8. [P4774 [NOI2018] 屠龙勇士](https://www.luogu.com.cn/problem/P4774)
9. [P6136 【模板】普通平衡树(数据加强版)](https://www.luogu.com.cn/problem/P6136)
10. [U361730 【模板】完全体·堆](https://www.luogu.com.cn/problem/U361730)
11. [翻转排序](https://ac.nowcoder.com/acm/problem/275173)
12. [旅途的终点](https://ac.nowcoder.com/acm/problem/275989)
13. [正义从不打背身](https://ac.nowcoder.com/acm/problem/277862)
14. [Range Reverse Range Sum](https://judge.yosupo.jp/problem/range_reverse_range_sum)(https://github.com/yosupo06/library-checker-problems/issues/538)
5. [P2032 扫描](https://www.luogu.com.cn/problem/P2032)
6. [P3369 【模板】普通平衡树](https://www.luogu.com.cn/problem/P3369)
7. [P3391 【模板】文艺平衡树](https://www.luogu.com.cn/problem/P3391)
8. [P4036 [JSOI2008] 火星人](https://www.luogu.com.cn/problem/P4036)
9. [P4774 [NOI2018] 屠龙勇士](https://www.luogu.com.cn/problem/P4774)
10. [P6136 【模板】普通平衡树(数据加强版)](https://www.luogu.com.cn/problem/P6136)
11. [U361730 【模板】完全体·堆](https://www.luogu.com.cn/problem/U361730)
12. [翻转排序](https://ac.nowcoder.com/acm/problem/275173)
13. [旅途的终点](https://ac.nowcoder.com/acm/problem/275989)
14. [正义从不打背身](https://ac.nowcoder.com/acm/problem/277862)
15. [Range Reverse Range Sum](https://judge.yosupo.jp/problem/range_reverse_range_sum)(https://github.com/yosupo06/library-checker-problems/issues/538)


### 二、模板功能
Expand Down
22 changes: 21 additions & 1 deletion DS/MonoZkwTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ namespace OY {
struct FpTransfer {
Tp operator()(const Tp &x, const Tp &y) const { return Fp(x, y); }
};
#ifdef __cpp_lib_void_t
template <typename... Tp>
using void_t = std::void_t<Tp...>;
#else
template <typename... Tp>
struct make_void {
using type = void;
};
template <typename... Tp>
using void_t = typename make_void<Tp...>::type;
#endif
template <typename Tp, typename = void>
struct Has_Not_Equal : std::false_type {};
template <typename Tp>
struct Has_Not_Equal<Tp, void_t<decltype(std::declval<Tp>() != std::declval<Tp>())>> : std::true_type {};
template <typename Monoid>
class Tree {
public:
Expand All @@ -43,7 +58,12 @@ namespace OY {
private:
size_type m_size, m_cap;
std::vector<value_type> m_sub;
static bool _check_pushup(value_type &old, value_type val) { return old != val ? old = val, true : false; }
static bool _check_pushup(value_type &old, value_type val) {
if constexpr (Has_Not_Equal<value_type>::value)
return old != val ? old = val, true : false;
else
return old = val, true;
}
public:
Tree(size_type length = 0) { resize(length); }
template <typename InitMapping>
Expand Down
23 changes: 14 additions & 9 deletions DS/MonoZkwTree.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
2. [Mosaic](https://acm.hdu.edu.cn/showproblem.php?pid=4819)
3. [#130. 树状数组 1 :单点修改,区间查询](https://loj.ac/p/130)
4. [#131. 树状数组 2 :区间修改,单点查询](https://loj.ac/p/131)
5. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
6. [P1890 gcd区间](https://www.luogu.com.cn/problem/P1890)
7. [P3368 【模板】树状数组 2](https://www.luogu.com.cn/problem/P3368)
8. [P3374 【模板】树状数组 1](https://www.luogu.com.cn/problem/P3374)
9. [P3865 【模板】ST 表](https://www.luogu.com.cn/problem/P3865)
10. [P4094 [HEOI2016/TJOI2016] 字符串](https://www.luogu.com.cn/problem/P4094)
11. [P4556 [Vani有约会] 雨天的尾巴 /【模板】线段树合并](https://www.luogu.com.cn/problem/P4556)
12. [U311262 求区间后继](https://www.luogu.com.cn/problem/U311262)
13. [Vertex Set Path Composite](https://judge.yosupo.jp/problem/vertex_set_path_composite)(https://github.com/yosupo06/library-checker-problems/issues/190)
5. [P1440 求m区间内的最小值](https://www.luogu.com.cn/problem/P1440)
6. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
7. [P1890 gcd区间](https://www.luogu.com.cn/problem/P1890)
8. [P2032 扫描](https://www.luogu.com.cn/problem/P2032)
9. [P3368 【模板】树状数组 2](https://www.luogu.com.cn/problem/P3368)
10. [P3374 【模板】树状数组 1](https://www.luogu.com.cn/problem/P3374)
11. [P3865 【模板】ST 表](https://www.luogu.com.cn/problem/P3865)
12. [P4094 [HEOI2016/TJOI2016] 字符串](https://www.luogu.com.cn/problem/P4094)
13. [P4513 小白逛公园](https://www.luogu.com.cn/problem/P4513)
14. [P4556 [Vani有约会] 雨天的尾巴 /【模板】线段树合并](https://www.luogu.com.cn/problem/P4556)
15. [P6373 「StOI-1」IOI计数](https://www.luogu.com.cn/problem/P6373)
16. [U311262 求区间后继](https://www.luogu.com.cn/problem/U311262)
17. [研究red子序列的红](https://ac.nowcoder.com/acm/problem/281740)
18. [Vertex Set Path Composite](https://judge.yosupo.jp/problem/vertex_set_path_composite)(https://github.com/yosupo06/library-checker-problems/issues/190)

### 二、模板功能

Expand Down
13 changes: 7 additions & 6 deletions DS/SegmentBeat.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
7. [P4314 CPU 监控](https://www.luogu.com.cn/problem/P4314)
8. [P4560 [IOI2014] Wall 砖墙](https://www.luogu.com.cn/problem/P4560)
9. [P6242 【模板】线段树 3](https://www.luogu.com.cn/problem/P6242)
10. [U180387 CTSN loves segment tree](https://www.luogu.com.cn/problem/U180387)
11. [#164. 【清华集训2015】V](https://uoj.ac/problem/164)
12. [#169. 【UR #11】元旦老人与数列](https://uoj.ac/problem/169)
13. [#170. Picks loves segment tree VIII](https://uoj.ac/problem/170)
14. [#228. 基础数据结构练习题](https://uoj.ac/problem/228)
15. [Range Chmin Chmax Add Range Sum](https://judge.yosupo.jp/problem/range_chmin_chmax_add_range_sum)(https://github.com/yosupo06/library-checker-problems/issues/243)
10. [P10639 BZOJ4695 最佳女选手](https://www.luogu.com.cn/problem/P10639)
11. [U180387 CTSN loves segment tree](https://www.luogu.com.cn/problem/U180387)
12. [#164. 【清华集训2015】V](https://uoj.ac/problem/164)
13. [#169. 【UR #11】元旦老人与数列](https://uoj.ac/problem/169)
14. [#170. Picks loves segment tree VIII](https://uoj.ac/problem/170)
15. [#228. 基础数据结构练习题](https://uoj.ac/problem/228)
16. [Range Chmin Chmax Add Range Sum](https://judge.yosupo.jp/problem/range_chmin_chmax_add_range_sum)(https://github.com/yosupo06/library-checker-problems/issues/243)

### 二、模板功能

Expand Down
8 changes: 5 additions & 3 deletions DS/SparseTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

​ 练习题目:

1. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
2. [P1890 gcd区间](https://www.luogu.com.cn/problem/P1890)
3. [P3865 【模板】ST 表](https://www.luogu.com.cn/problem/P3865)
1. [P1440 求m区间内的最小值](https://www.luogu.com.cn/problem/P1440)
2. [P1886 滑动窗口 /【模板】单调队列](https://www.luogu.com.cn/problem/P1886)
3. [P1890 gcd区间](https://www.luogu.com.cn/problem/P1890)
4. [P2032 扫描](https://www.luogu.com.cn/problem/P2032)
5. [P3865 【模板】ST 表](https://www.luogu.com.cn/problem/P3865)

### 二、模板功能

Expand Down
1 change: 1 addition & 0 deletions DS/Splay.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ namespace OY {
if (!m_rt) return _ptr(0);
state_type state = 0;
if (!_lower_bound(key)) return _update_root(), root();
_update_root();
size_type lc = root()->m_lc;
if (!lc) return _ptr(0);
if (!_splay_max(&lc)) _rotate_l(&lc);
Expand Down
74 changes: 0 additions & 74 deletions DS/WindowRMQ.h

This file was deleted.

Loading

0 comments on commit 4d155ec

Please sign in to comment.