bzoj4364: [Ioi2014]wall brick wall

Source: Internet
Author: User

Good (Luo) question for line segment tree marking

Hit Mark, remember to move Down

= = heard that 2000000 is used for card segment tree

= = What to do,,,

= = Make a read-in optimization see if you can get the card over there.

#include <cstdio>#include<algorithm>#include<cstring>using namespacestd;Const intm=2000010;intn,m,i,opt,l,r,x;intmx1[m*4],mx2[m*4];intRead () {intx=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}voidPushdown (intp) {    intl=p<<1,r=p<<1^1; if(Mx2[p]>mx1[l]) mx1[l]=mx2[l]=Mx2[p]; Else if(Mx2[p]>mx2[l]) mx2[l]=Mx2[p]; if(Mx2[p]>mx1[r]) mx1[r]=mx2[r]=Mx2[p]; Else if(Mx2[p]>mx2[r]) mx2[r]=Mx2[p]; if(Mx1[p]<mx2[l]) mx1[l]=mx2[l]=Mx1[p]; Else if(Mx1[p]<mx1[l]) mx1[l]=Mx1[p]; if(Mx1[p]<mx2[r]) mx1[r]=mx2[r]=Mx1[p]; Else if(Mx1[p]<mx1[r]) mx1[r]=mx1[p];}voidPushup (intp) {    intl=p<<1,r=p<<1^1; MX1[P]=Max (Mx1[l],mx1[r]); MX2[P]=min (mx2[l],mx2[r]);}voidUpdate1 (intXintYintLintRintPintt) {    if(x==l&&y==R) {Mx1[p]=Max (mx1[p],t); MX2[P]=Max (mx2[p],t); return; }    intMid=l+r>>1;    Pushdown (P); if(Y<=mid) update1 (x,y,l,mid,p<<1, T); Else if(X>mid) update1 (x,y,mid+1,r,p<<1^1, T); ElseUpdate1 (x,mid,l,mid,p<<1, t), Update1 (mid+1, y,mid+1,r,p<<1^1, T); Pushup (P);}voidUpdate2 (intXintYintLintRintPintt) {    if(x==l&&y==R) {Mx1[p]=min (mx1[p],t); MX2[P]=min (mx2[p],t); return; }    intMid=l+r>>1;    Pushdown (P); if(Y<=mid) Update2 (x,y,l,mid,p<<1, T); Else if(X>mid) Update2 (x,y,mid+1,r,p<<1^1, T); ElseUpdate2 (x,mid,l,mid,p<<1, t), Update2 (mid+1, y,mid+1,r,p<<1^1, T); Pushup (P);}voidBuildintLintRintp) {    if(l==R) {printf ("%d\n", Mx1[p]); return; }    intMid=l+r>>1;    Pushdown (P); Build (L,mid,p<<1); Build (Mid+1,r,p<<1^1);}intMain () {n=read (), m=read ();  for(i=1; i<=m;i++) {opt=read (); L=read (), R=read (), x=read (); L++;r++; if(opt==1) update1 (L,r,1N1, x); ElseUpdate2 (L,r,1N1, x); }} Build (1N1);}

And it stinks and grows +1.

Two updates can be combined, but too lazy to change

bzoj4364: [Ioi2014]wall brick wall

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.