bzoj3211 the world of flowers and Gods

Source: Internet
Author: User

Segment Tree Interval root ... Direct violence changes to leaves.

Start array open small re ...

#include <cstdio>#include<cstring>#include<cmath>#include<ctime>#include<cstdlib>#include<iostream>#include<algorithm>#defineL (a) (((a) <<1))#defineR (a) (((a) <<1) +1)#defineCLR (a,x) memset (A,x,sizeof (a))#defineRep (i,l,r) for (int i=l;i<r;i++)typedefLong Longll;using namespacestd;intRead () {CharC=GetChar (); intans=0, f=1;  while(!IsDigit (c)) {        if(c=='-') f=-1; C=GetChar (); }     while(IsDigit (c)) {ans=ans*Ten+c-'0'; C=GetChar (); }    returnans*F;}Const intmaxn=500010;structnode{intl,r,mx; ll sum;}; Node X[MAXN];voidMaintain (inta) {x[a].mx=Max (X[l (a)].mx,x[r (a)].mx); X[a].sum=x[l (a)].sum+X[r (a)].sum;}voidBuildintAintLintR) {X[A].L=l,x[a].r=R; if(l==R) {x[a].mx=x[a].sum=read (); return; }    intMid= (l+r) >>1;    Build (L (a), l,mid); Build (R (a), Mid+1, R); Maintain (a);} ll find (intAintLintR) {        if(l==x[a].l&&r==X[A].R) {        returnx[a].sum; }    intMid= (X[A].L+X[A].R) >>1; if(R<=mid)returnFind (L (a), l,r); if(L>mid)returnFind (R (a), l,r); returnFind (L (a), L,mid) +find (R (a), mid+1, R);}voidModifyintAintLintR) {        if(x[a].mx<=1)return; if(x[a].l==X[A].R) {X[a].sum=Floor (sqrt (x[a].sum)); X[a].mx=Floor (sqrt (x[a].mx)); return; }    intMid= (X[A].L+X[A].R) >>1; if(r<=mid) Modify (L (a), l,r); Else if(l>mid) Modify (R (a), l,r); Else{Modify (L (a), l,mid); Modify (R (a), Mid+1, R); } maintain (a);}intMain () {CLR (x,0); intn=read (); Build (1,1, N); intm=read ();  while(m--){        intOpt=read (), L=read (), r=read (); if(opt==1) {printf ("%lld\n", Find (1, L,r)); }Else{Modify (1, L,r); }    }    return 0;}
View Code 3211: The flower God travels the country time Limit:5 Sec Memory limit:128 MB
submit:1420 solved:548
[Submit] [Status] [Discuss] Description Input Output

Each time x=1, an integer per line indicates the pleasure of this trip

Sample Input4

1 100 5 5

5

1 1 2

2 1 2

1 1 2

2 2 3

1 1 4

Sample Output101

11

11

HINT

For 100% data, n≤100000,m≤200000, Data[i] is non-negative and less than 10^9


Source

SPOJ2713 GSS4 data has been enhanced

[Submit] [Status] [Discuss]

bzoj3211 the world of flowers and Gods

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.