Point modification interval Query HDU1754

Source: Internet
Author: User

1#include <iostream>2#include <cstdio>3 4 using namespacestd;5 6 intan[200010];7 structNode8 {9     intl;Ten     intR; One     intMa; A}bn[800010]; -  - voidBuildintKintLintR) the { -Bn[k].l=l; -Bn[k].r=R; -     if(l==R) +     { -Bn[k].ma=An[l]; +         return ; A     } at     intlk=k*2; -     intrk=lk+1; -     intMid= (L+R)/2; - build (Lk,l,mid); -Build (rk,mid+1, R); -Bn[k].ma=Max (bn[lk].ma,bn[rk].ma); in } -  to voidChangeintKintIinta) + { -     if(bn[k].l==i&&bn[k].r==i) the     { *Bn[k].ma=A; $         return ;Panax Notoginseng     } -     intlk=k*2; the     intrk=lk+1; +     if(bn[lk].r>=i) A Change (lk,i,a); the     Else if(bn[rk].l<=i) + Change (rk,i,a); -Bn[k].ma=Max (bn[lk].ma,bn[rk].ma); $ } $  - intSearchintKintLintR) - { the     if(bn[k].l==l&&bn[k].r==R) -     {Wuyi         returnbn[k].ma; the     } -     intlk=k*2; Wu     intrk=lk+1; -     if(bn[lk].r>=R) About         returnsearch (lk,l,r); $     Else if(bn[rk].l<=l) -         returnsearch (rk,l,r); -     Else -         returnMax (Search (LK,L,BN[LK].R), search (rk,bn[rk].l,r)); A } +  the intMain () - { $     intn,m; the      while(SCANF ("%d%d", &n,&m)! =EOF) the     { the          for(intI=1; i<=n;i++) thescanf"%d",&an[i]); -Build1,1, n); in          for(intI=0; i<m;i++) the         { the             CharCA; About             intb; thescanf"%c",&CA); thescanf"%d%d",&a,&b); the             if(ca=='Q') +printf"%d\n", Search (1, A, b)); -             Else if(ca=='U') theChange1, A, b);Bayi         } the     } the     return 0; -}
View Code

Point modification interval Query HDU1754

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.