Skip to content

Commit 1dfbec9

Browse files
committed
update docs
1 parent eab32b9 commit 1dfbec9

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

library/data_structures_[l,r)/seg_tree.hpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22
//! https://github.com/kth-competitive-programming/kactl/blob/main/content/data-structures/SegmentTree.h
33
//! https://codeforces.com/blog/entry/118682
44
//! @code
5-
//! tree st1(n, INT_MAX, ranges::min);
6-
//! tree st2(n, INT_MAX, [&](int x, int y) -> int {
7-
//! return min(x, y);
5+
//! tree st1(n, 0, [&](int vl, int vr) {
6+
//! return vl + vr;
87
//! });
9-
//! int idx = st2.walk(l, r, [&](int value) {
10-
//! return value > x;
11-
//! }); // min idx in [l, r) such that f is false
8+
//! tree st(a, ranges::min);
9+
//! int idx = st.max_right(l, r, [&](int value) {
10+
//! return value <= x;
11+
//! });
12+
//! // idx in [l, r]
13+
//! // f(op(a[l], a[l+1], ..., a[idx-1])) is true
14+
//! // f(op(a[l], a[l+1], ..., a[idx])) is false
15+
//! idx = st.min_left(l, r, [&](int value) {
16+
//! return value <= x;
17+
//! });
18+
//! // idx in [l, r]
19+
//! // f(op(a[idx+1], ..., a[r-2], a[r-1])) is true
20+
//! // f(op(a[idx], ..., a[r-2], a[r-1])) is false
1221
//! @endcode
1322
//! @time O(n + q log n)
1423
//! @space O(n)

library/data_structures_[l,r]/seg_tree.hpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
#pragma once
22
//! https://codeforces.com/blog/entry/118682
33
//! @code
4-
//! {
5-
//! tree st(a, [&](int vl, int vr) {
6-
//! return vl & vr;
7-
//! });
8-
//! }
9-
//! {
10-
//! tree st(n, 0LL, plus<ll>{});
11-
//! }
12-
//! {
13-
//! tree st(n, INT_MAX, ranges::min);
14-
//! int idx = st.walk(l, r, [&](int value) {
15-
//! return value <= x;
16-
//! }); // smallest index in [l, r] s.t. f is false
17-
//! }
4+
//! tree st1(n, 0, [&](int vl, int vr) {
5+
//! return vl + vr;
6+
//! });
7+
//! tree st(a, ranges::min);
8+
//! int idx = st.max_right(l, r, [&](int value) {
9+
//! return value <= x;
10+
//! });
11+
//! // idx in [l, r+1]
12+
//! // f(op(a[l], a[l+1], ..., a[idx-1])) is true
13+
//! // f(op(a[l], a[l+1], ..., a[idx])) is false
14+
//! idx = st.min_left(l, r, [&](int value) {
15+
//! return value <= x;
16+
//! });
17+
//! // idx in [l-1, r]
18+
//! // f(op(a[idx+1], ..., a[r-1], a[r])) is true
19+
//! // f(op(a[idx], ..., a[r-1], a[r])) is false
1820
//! @endcode
1921
//! @time O(n + q log n)
2022
//! @space O(n)

0 commit comments

Comments
 (0)