WA a piece, the last T, finally heart-broken ...
Why didn't anyone tell me to drive Longlong?
Why does everybody say there's no negative?
1#include <cstdio>2#include <algorithm>3 #defineMid ((l+r) >>1)4 using namespacestd;5 Long LongCas,a,b,c,k,l,r,n,m,sz;6 introot[200005];7 intls[10000005],rs[10000005],sum[10000005],lazy[10000005];8 voidPushdown (intKintLintR)9 {Ten if(!lazy[k]| | L==R)return; One if(!ls[k]) ls[k]=++sz; A if(!rs[k]) rs[k]=++sz; -lazy[ls[k]]+=lazy[k];lazy[rs[k]]+=Lazy[k]; -sum[ls[k]]+= (mid-l+1)*Lazy[k]; thesum[rs[k]]+= (R-MID) *Lazy[k]; -lazy[k]=0; - } - voidAddintKintLintRintAintb) + { - if(l==a&&r==b) + { Asum[k]+=r-l+1; atlazy[k]++; - return; - } - pushdown (k,l,r); - if(A<=mid) ls[k]=ls[k]?ls[k]:++Sz,add (Ls[k],l,mid,a,min (B,mid)); - if(B>mid) Rs[k]=rs[k]?rs[k]:++sz,add (rs[k],mid+1, R,max (mid+1, a), b); insum[k]=sum[ls[k]]+Sum[rs[k]]; - } to Long LongQueintKintLintRintAintb) + { - if(!k)return 0; the if(l==a&&r==b)returnSum[k]; * pushdown (k,l,r); $ if(B<=mid)returnque (ls[k],l,mid,a,b);Panax Notoginseng Else if(A>mid)returnQue (rs[k],mid+1, r,a,b); - Else returnQue (ls[k],l,mid,a,mid) +que (rs[k],mid+1, r,mid+1, b); the } + intSolve () A { the intL=1, r=2*n,k=1; + while(l!=R) - { $ Long LongT=que (root[k<<1|1],1, n,a,b); $ if(c<=t) l=mid+1,k=k<<1|1; - Elser=mid,k=k<<1, c-=T; - } the returnl; - }Wuyi intMain () the { - for(SCANF ("%d%d", &n,&m); m;m--) Wu { -scanf"%d%d%d%d",&cas,&a,&b,&c); About if(cas==1) $ for(k=1, l=1, r=2*n,c+=n;l!=r;root[k]=root[k]?root[k]:++sz,add (Root[k],1, n,a,b)) - if(C<=mid) r=mid,k=k<<1; - ElseL=mid+1,k=k<<1|1; - Elseprintf"%d\n", Solve ()-n); A } + return 0; the}
This time the code is still quite beautiful.
"Impossible task 16/200" bzoj3110 Tree Set Tree