@@ -30,12 +30,12 @@ template <class S, S (*op)(S, S), S (*e)()> struct segtree {
30
30
for (int i = 1 ; i <= log ; i++) update (p >> i);
31
31
}
32
32
33
- S get (int p) {
33
+ S get (int p) const {
34
34
assert (0 <= p && p < _n);
35
35
return d[p + size];
36
36
}
37
37
38
- S prod (int l, int r) {
38
+ S prod (int l, int r) const {
39
39
assert (0 <= l && l <= r && r <= _n);
40
40
S sml = e (), smr = e ();
41
41
l += size;
@@ -50,12 +50,12 @@ template <class S, S (*op)(S, S), S (*e)()> struct segtree {
50
50
return op (sml, smr);
51
51
}
52
52
53
- S all_prod () { return d[1 ]; }
53
+ S all_prod () const { return d[1 ]; }
54
54
55
- template <bool (*f)(S)> int max_right (int l) {
55
+ template <bool (*f)(S)> int max_right (int l) const {
56
56
return max_right (l, [](S x) { return f (x); });
57
57
}
58
- template <class F > int max_right (int l, F f) {
58
+ template <class F > int max_right (int l, F f) const {
59
59
assert (0 <= l && l <= _n);
60
60
assert (f (e ()));
61
61
if (l == _n) return _n;
@@ -79,10 +79,10 @@ template <class S, S (*op)(S, S), S (*e)()> struct segtree {
79
79
return _n;
80
80
}
81
81
82
- template <bool (*f)(S)> int min_left (int r) {
82
+ template <bool (*f)(S)> int min_left (int r) const {
83
83
return min_left (r, [](S x) { return f (x); });
84
84
}
85
- template <class F > int min_left (int r, F f) {
85
+ template <class F > int min_left (int r, F f) const {
86
86
assert (0 <= r && r <= _n);
87
87
assert (f (e ()));
88
88
if (r == 0 ) return 0 ;
0 commit comments