forked from atcoder/ac-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredblacklazysegtree.test.cpp
46 lines (42 loc) · 1.12 KB
/
redblacklazysegtree.test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1508"
#include <atcoder/rb_lazysegtree>
#include <iostream>
#include <limits>
using namespace atcoder;
using namespace std;
int op(int a, int b) { return min(a,b); }
int e() { return numeric_limits<int>::max(); }
int id() { return numeric_limits<int>::max(); }
int mapping(int a, int b) {
if (a==id()) return b;
return a;
}
int composition(int a, int b) {
if (a==id()) return b;
if (b==id()) return a;
return b;
}
int main() {
int n, q; cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
RBLazySegtree<int,op,e,int,mapping,composition,id> tree(n);
tree.build(a);
while (q--) {
int t; cin >> t;
if (t == 0) {
int l, r; cin >> l >> r;
int val = tree.erase(r);
tree.insert(l, val);
}
if (t == 1) {
int l, r; cin >> l >> r;
cout << tree.prod(l, r+1) << endl;
}
if (t == 2) {
int pos, val; cin >> pos >> val;
tree.apply(pos, pos+1, val);
}
}
return 0;
}