"BZOJ3211" Flower Gods travel around the tree array and check the averaging analysis

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.