Stars in Your Window POJ-2482

Source: Internet
Author: User

Error logging:

The title says that the input is in the range of int, but it may be super int during the operation; and then a lot of longlong.

1#include <cstdio>2#include <algorithm>3#include <cstring>4#include <vector>5#include <map>6 using namespacestd;7 #defineFi first8 #defineSe Second9 #defineMP Make_pairTen #definePB Push_back OnetypedefLong Longll; Atypedef unsignedLong Longull; -typedef pair<int,int>Pi; - structQ the { -ll X1,x2,y;intC,type; -}q[20100]; - intNQ; + BOOL operator< (ConstQ &a,ConstQ &b) - { +     returna.y<b.y| | (a.y==b.y&&a.type<b.type); A } at intn,w,h; - ll ans; - namespaceS - { - #defineLC (NUM&LT;&LT;1) - #defineRC (num<<1|1) in #defineMid (L + ((r-l) >>1)) -ll d[200100],addv[200100]; to voidBuildintLintRintnum) + { -     if(L==R) {d[num]=addv[num]=0;return;} theBuild (L,MID,LC); Build (mid+1, R,RC); *d[num]=addv[num]=0; $ }Panax Notoginseng intl,r;ll x; - voidPdintLintRintnum) the { +D[lc]+=addv[num];d [rc]+=Addv[num]; Aaddv[lc]+=addv[num];addv[rc]+=Addv[num]; theaddv[num]=0; + } - void_ADDX (intLintRintnum) $ { $     if(l<=l&&r<=R) -     { -d[num]+=x;addv[num]+=x; the         return; -     }Wuyi PD (l,r,num); the     if(l<=mid) _addx (L,MID,LC); -     if(mid<r) _ADDX (mid+1, R,RC); Wud[num]=Max (D[LC],D[RC]); - } Aboutll _que (intLintRintnum) $ { -     if(L&LT;=L&AMP;&AMP;R&LT;=R)returnD[num]; - PD (l,r,num); -ll ans=0; A     if(L<=mid) ans=Max (Ans,_que (L,MID,LC)); +     if(mid<r) Ans=max (Ans,_que (mid+1, R,RC)); the     returnans; - } $ #undefLc the #undefRc the #undefMid the } theMap<ll,ll>Ma; -ll t0[200100]; in intMain () the { the     inti;ll a,b,c; About      while(SCANF ("%d%d%d", &n,&w,&h) = =3) the     { thenq=0; the          for(i=1; i<=n;i++) +         { -scanf"%lld%lld%lld",&a,&b,&c); theq[++nq].y=a-w+1; q[nq].x1=b-h+1; q[nq].x2=b;q[nq].c=c;q[nq].type=1;Bayiq[++nq].y=a+1; q[nq].x1=b-h+1; q[nq].x2=b;q[nq].c=c;q[nq].type=0; the         } theans=0; -t0[0]=0; -          for(i=1; i<=nq;i++) t0[++t0[0]]=q[i].x1,t0[++t0[0]]=q[i].x2; theSort (t0+1, t0+t0[0]+1); t0[0]=unique (t0+1, t0+t0[0]+1)-t0-1; the ma.clear (); the          for(i=1; i<=t0[0];i++) ma[t0[i]]=i; the          for(i=1; i<=nq;i++) q[i].x1=ma[q[i].x1],q[i].x2=ma[q[i].x2]; -Sort (q+1, q+nq+1); theS::build (1, t0[0],1); the          for(i=1; i<=nq;i++) the         {94             if(q[i].type==0) the             { thes::l=q[i].x1; s::r=q[i].x2; s::x=-q[i].c; theS::_ADDX (1, t0[0],1);98             } About             Else -             {101s::l=q[i].x1; s::r=q[i].x2; s::x=q[i].c;102S::_ADDX (1, t0[0],1);103             }104             if(i==nq| | q[i].y!=q[i+1].y) the             {106S::l=1; s::r=t0[0];107Ans=max (Ans,s::_que (1, t0[0],1));108             }109         } theprintf"%lld\n", ans);111     } the     return 0;113}

Stars in Your Window POJ-2482

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.