Link:
#include <stdio.h>int main(){ puts("转载请注明出处[vmurder]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/44686727");}
Exercises
A few times a point to open the side is gone. So we just need to change the point that is not 0 or 1.
Averaging basic O(n) 。
Then use and check the set to maintain a point to the right of the first is not a number 0.
Handwriting read into the tall. Card rank artifact.
By the way Orz Wys the great God.
Code:
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N 100100using namespace STD;inline intGetc () {Static Const intL =1<< the;Static CharBuf[l], *s = buf, *t = buf;if(S = = T) {T = (S = buf) + fread (buf,1, L, stdin);if(S = = T)returnEOF; }return*s++;}inline intGetint () {intC while(!IsDigit(c = getc ()) && c! ='-');BOOLSign = c = ='-';intTMP = sign?0C' 0 '; while(IsDigit(c = getc ())) TMP = (tmp <<1) + (TMP <<3) + C-' 0 ';returnSign? -tmp:tmp;}intN,m,v[n],f[n];Long LongA[n];inline intFindintx) {returnF[x]==x?x:f[x]=find (F[x]);}inline voidAddintXintW) { while(x<=n) A[x]+=w,x+=x&-x;}inline Long LongAskintx) {Long Longret=0; while(x) ret+=a[x],x-=x&-x;returnRET;}inline voidEditintLintR) { for(; L<=r;l=find (L +1)) {intT= (int)sqrt(V[l]); Add (L,t-v[l]), v[l]=t;if(v[l]<=1) F[l]=find (L +1); }}intMain () {Freopen ("Test.in","R", stdin);intI,a,b,c; N=getint (); for(i=1; i<=n+5; i++) f[i]=i; for(i=1; i<=n;i++) {v[i]=getint ();if(v[i]<=1) f[i]=i+1; Add (I,v[i]); } for(M=getint (); m--;) {A=getint (), B=getint (), C=getint ();if(a==1)printf("%lld\n", ask (c)-ask (b-1));ElseEdit (B,C); }}
"BZOJ3211" flower Gods travel around the tree array and check the averaging analysis