#line 1 "a.cpp" #include #include #include using namespace std; #line 2 "/home/kotatsugame/library/datastructure/segtree.cpp" #include #include template struct segtree{ using F=function; const F calcfn,updatefn; int n; T defvalue; vectordat; segtree(int n_=0,T defvalue_=numeric_limits::max(), const F calcfn_=[](T a,T b){return a&v) { for(int i=0;i=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]); } void update(int i,T a) { i+=n-1; dat[i]=updatefn(dat[i],a); while(i>0) { i=(i-1)/2; dat[i]=calcfn(dat[2*i+1],dat[2*i+2]); } } T query(int a,int b)//[a,b) { int L=(a<0?0:a>n?n:a)+n-1; int R=(b<0?0:b>n?n:b)+n-1; T lret=defvalue,rret=defvalue; for(;L>=1,R>>=1) { if(!(L&1))lret=calcfn(lret,dat[L]); if(!(R&1))rret=calcfn(dat[--R],rret); } return calcfn(lret,rret); } }; #line 6 "a.cpp" int N; int ans[1<<17]; main() { cin>>N; vector > > >X; segtreeL(N,-1e9,[](int a,int b){return aR(N,2e9,[](int a,int b){return a>x; X.push_back(make_pair(x,make_pair(i,make_pair(-1,-1)))); R.update(i,x); } int Q;cin>>Q; for(int i=0;i>l>>r>>x; l--; X.push_back(make_pair(x,make_pair(i,make_pair(l,r)))); } sort(X.begin(),X.end()); for(int i=0;i