#include #include #include #include using namespace std; using ll = long long; template struct lazytree{ int N; Tr iden; vector tree; La lazyiden; vector lazy; int pow2(int n){ int ans=1; while(ans=1; i--) tree[i]=opt(tree[2*i], tree[2*i+1]); } void apply(int k, La x, int l, int r){ ltot(tree[k], x, l, r); composition(lazy[k], x); } void push(int k, int l, int r){ //自分に溜まったlazyを子に伝える if(lazy[k]==lazyiden||l==r) return; int mid=(l+r)/2; apply(2*k, lazy[k], l, mid); apply(2*k+1, lazy[k], mid+1, r); lazy[k]=lazyiden; } void update(int s, int t, La x, int k=1, int l=1, int r=-1){ //s, tは1-indexed! if(r<0) r=N; if(t> n >> a; map pos, dict; vector x(n); for(auto&y:x) cin >> y, pos[y]++; int t; cin >> t; vector l(t), r(t); for(int i=0; i> l[i] >> r[i]; pos[l[i]]++; pos[r[i]]++; } { int c=1; for(auto [y, _]:pos) dict[y]=c++; } int m=dict.size(); lazytree seg; seg.build(m); for(int i=0; i