A value of two minutes, and then the segment tree is simulated.
#include <bits/stdc++.h>#defineLson (o<<1)#defineRson (o<<1|1)Const intn=1e5+Ten;using namespacestd;intn,m,a[n],x,q;structopt{intOpt,l,r,id;} B[n];structsegment_tree{intsumv[n<<2],setv[n<<2]; InlinevoidPushup (intO) {sumv[o]=sumv[lson]+Sumv[rson];} InlinevoidPushdown (intOintLintR) { if(setv[o]==-1)return; intTag=setv[o],mid= (l+r) >>1; Setv[lson]=tag;sumv[lson]=tag* (mid-l+1); Setv[rson]=tag;sumv[rson]=tag* (Rmid); Setv[o]=-1; } InlinevoidBuildintOintLintR) {Sumv[o]=0; setv[o]=-1; if(L==R) {sumv[o]=a[l]>x;return;} intMid= (l+r) >>1; Build (Lson,l,mid); Build (Rson,mid+1, R); Pushup (o); } intQuerysum (intOintLintRintQlintqr) { if(QL<=L&&R<=QR)returnSumv[o]; intMid= (l+r) >>1, ans=0; Pushdown (O,L,R); if(Ql<=mid) ans+=querysum (LSON,L,MID,QL,QR); if(Qr>mid) Ans+=querysum (rson,mid+1, R,QL,QR); returnans; } voidIsetintOintLintRintQlintQrintv) { if(QL<=L&&R<=QR) {setv[o]=v;sumv[o]=v* (r-l+1);return;} intMid= (l+r) >>1; Pushdown (O,L,R); if(ql<=mid) Iset (LSON,L,MID,QL,QR,V); if(Qr>mid) Iset (rson,mid+1, r,ql,qr,v); Pushup (o); }}t;inlineBOOLCheckintVV) {x=VV; T.build (1,1, N); for(intI=1; i<=m;i++){ intOpt=b[i].opt,l=b[i].l,r=B[I].R; intTmp=t.querysum (1,1, N,l,r); if(opt==0) {T.iset (1,1, N,l,r-tmp,0); T.iset (1,1, n,r-tmp+1R1); } Else{T.iset (1,1, n,l,l+tmp-1,1); T.iset (1,1, N,l+tmp,r,0); } } return! T.querysum (1,1, n,q,q);} InlineintRead () {intf=1, x=0;Charch; Do{Ch=getchar ();if(ch=='-') f=-1;} while(ch<'0'|| Ch>'9'); Do{x=x*Ten+ch-'0'; Ch=getchar ();} while(ch>='0'&&ch<='9'); returnf*x;}intMain () {n=read (); M=read (); for(intI=1; i<=n;i++) a[i]=read (); for(intI=1; i<=m;i++) {b[i].opt=read (); B[i].l=read (); b[i].r=read ();} Q=read ();intL=1, r=N; while(l<R) { intMid= (l+r) >>1; if(Check (mid)) r=mid; ElseL=mid+1; } printf ("%d\n", R);}
Sort "bzoj4552"