bzoj1513: [Poi2006]tet-tetris 3D

Source: Internet
Author: User

Descriptiontask:tetris 3D "Tetris" the author of the game decided to make a new game, a three-dimensional version, in which a lot of cubes fell on the flat plate, and a cube began to fall until it hit a previously falling cube or landed and stopped. The author wants to change the purpose of the game to make it more popular, in the new game you will know the drop of the cube information and location, your task is to answer all the cubes fall after the highest block height. All cubes are vertical and do not rotate during the fall. The bottom left corner coordinates are the origin and are parallel to the axis .InputThe first line gives three integers D, S and N (1<= n<=, 1<= D, S <=1 000), respectively, representing the length and width of the plate and the number of drop cubes. The next N rows each line describes a cube. Each row contains 5 integers: D, S, W, X and Y (1<= D, 0 <=x, D + x<= D, 1 <=s, 0<= y, S + y<= s, 1<= W <=100 000), representing the length \ width of the cube, respectively \ High and lower left corner coordinates, both long and wide are parallel to the flat axis, and the four angular coordinates of the cube land after falling are: (x, Y), (x + D, y), (x, y + s) and (x + D, y + s).OutputAn integer representing the height of the highest block after all the cubes have fallen.

ZKW Segment Tree Set ZKW segment tree + tag Permanent maintenance interval max

#include <cstdio>intn,d,s;intx1,y1,x2,y2,h,ans,a0=0;inttr[2][2111][2111][2];Charbuf[2000000],*ptr=buf-1;int _(){    intx=0, c=*++ptr;  while(c< -) c=*++ptr;  while(c> -) x=x*Ten+c- -, c=*++ptr; returnx;} InlinevoidMAXS (int&a,intb) {if(a<b) a=b;}voidGint(*a) [2]){    intL=1023+y1,r=1025+y2,ld=0, rd=0;  for(; l^r^1; l>>=1, r>>=1){        if(LD) MAXS (ans,a[l][1]); if(RD) Maxs (ans,a[r][1]); if(~l&1) ld=1, Maxs (ans,a[l^1][0]); if(r&1) rd=1, Maxs (ans,a[r^1][0]); }    if(LD) MAXS (ans,a[l][1]); if(RD) Maxs (ans,a[r][1]);  for(l>>=1; l;l>>=1) Maxs (ans,a[l][1]);}voidSint(*a) [2]){    intL=1023+y1,r=1025+y2,ld=0, rd=0;  for(; l^r^1; l>>=1, r>>=1){        if(LD) MAXS (a[l][0],ans); if(RD) Maxs (a[r][0],ans); if(~l&1) ld=1, Maxs (a[l^1][0],ans), Maxs (a[l^1][1],ans); if(r&1) rd=1, Maxs (a[r^1][0],ans), Maxs (a[r^1][1],ans); }    if(LD) MAXS (a[l][0],ans); if(RD) Maxs (a[r][0],ans);  for(l>>=1; l;l>>=1) Maxs (a[l][0],ans);}voidcal () {ans=0; intL=1023+x1,r=1025+x2,ld=0, rd=0;  for(; l^r^1; l>>=1, r>>=1){        if(LD) G (tr[1][l]); if(RD) G (tr[1][r]); if(~l&1) ld=1, G (tr[0][l^1]); if(r&1) rd=1, G (tr[0][r^1]); }    if(LD) G (tr[1][l]); if(RD) G (tr[1][r]);  for(l>>=1; l;l>>=1) G (tr[1][l]); Ans+=h;    Maxs (A0,ans); L=1023+x1,r=1025+x2,ld=0, rd=0;  for(; l^r^1; l>>=1, r>>=1){        if(LD) s (tr[0][l]); if(RD) S (tr[0][r]); if(~l&1) ld=1, S (tr[0][l^1]), S (tr[1][l^1]); if(r&1) rd=1, S (tr[0][r^1]), S (tr[1][r^1]); }    if(LD) s (tr[0][l]); if(RD) S (tr[0][r]);  for(l>>=1; l;l>>=1) s (tr[0][l]);}intMain () {fread (buf,1,sizeof(BUF), stdin); D=_(); S=_ (); n=_();  for(intI=0; i<n;++i) {X2=_ (); Y2=_ (); h=_(); X1=_ (); y1=_(); X2+=x1;y2+=Y1; ++x1;++Y1;    Cal (); } printf ("%d", A0); return 0;}

bzoj1513: [Poi2006]tet-tetris 3D

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.