题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1513

题意:三维空间,有一些立方体在垂直下落。立方体的左下角坐标(x,y)以及长宽高d,s,w。A落在B上时将停止下落(即使A只有一小块跟B重合就算A会落在B上)。求最后最大的高度。

思路:每次覆盖时找到区域最大值,加上当前立方体的高度。

int xL,xR,yL,yR;
int h;

int n,m;

struct Seg
{
    int f[N<<1],s[N<<1];

    void insert(int t,int L,int R,int ll,int rr,int h)
    {
        f[t]=max(f[t],h);
        if(L==ll&&R==rr)
        {
            s[t]=max(s[t],h);
            return;
        }
        int M=(L+R)>>1;
        if(rr<=M) insert(t<<1,L,M,ll,rr,h);
        else if(ll>M) insert(t<<1|1,M+1,R,ll,rr,h);
        else
        {
            insert(t<<1,L,M,ll,M,h);
            insert(t<<1|1,M+1,R,M+1,rr,h);
        }
    }

    int query(int t,int L,int R,int ll,int rr)
    {
        if(L==ll&&R==rr) return f[t];

        int ans=s[t];
        int M=(L+R)>>1;
        if(rr<=M) upMax(ans,query(t<<1,L,M,ll,rr));
        else if(ll>M) upMax(ans,query(t<<1|1,M+1,R,ll,rr));
        else
        {
            upMax(ans,query(t<<1,L,M,ll,M));
            upMax(ans,query(t<<1|1,M+1,R,M+1,rr));
        }
        return ans;
    }
};

struct Seg1
{
    Seg f[N<<1],s[N<<1];

    void insert(int t,int L,int R,int ll,int rr)
    {
        f[t].insert(1,1,m,yL,yR,h);
        if(L==ll&&R==rr)
        {
            s[t].insert(1,1,m,yL,yR,h);
            return;
        }
        int M=(L+R)>>1;
        if(rr<=M) insert(t<<1,L,M,ll,rr);
        else if(ll>M) insert(t<<1|1,M+1,R,ll,rr);
        else
        {
            insert(t<<1,L,M,ll,M);
            insert(t<<1|1,M+1,R,M+1,rr);
        }
    }

    int query(int t,int L,int R,int ll,int rr)
    {
        if(L==ll&&R==rr) return f[t].query(1,1,m,yL,yR);
        int ans=s[t].query(1,1,m,yL,yR);
        int M=(L+R)>>1;
        if(rr<=M) upMax(ans,query(t<<1,L,M,ll,rr));
        else if(ll>M) upMax(ans,query(t<<1|1,M+1,R,ll,rr));
        else
        {
            upMax(ans,query(t<<1,L,M,ll,M));
            upMax(ans,query(t<<1|1,M+1,R,M+1,rr));
        }
        return ans;
    }
};

Seg1 a;

int Q;

int main()
{
    RD(n,m,Q);
    while(Q--)
    {
        int d,s,w,x,y;
        scanf("%d%d%d%d%d",&d,&s,&w,&x,&y);
        xL=x+1;
        xR=x+d;
        yL=y+1;
        yR=y+s;
        h=a.query(1,1,n,xL,xR);
        h+=w;
        a.insert(1,1,n,xL,xR);
    }
    xL=yL=1;
    xR=n;
    yR=m;
    int ans=a.query(1,1,n,1,n);
    printf("%d\n",ans);
}

BZOJ 1513 [POI2006]Tet-Tetris 3D的更多相关文章

  1. bzoj 1513 [POI2006]Tet-Tetris 3D(二维线段树)

    1513: [POI2006]Tet-Tetris 3D Time Limit: 30 Sec  Memory Limit: 162 MBSubmit: 540  Solved: 175[Submit ...

  2. bzoj 1513 POI2006 Tet-Tetris 3D 二维线段树+标记永久化

    1511: [POI2006]OKR-Periods of Words Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 351  Solved: 220[S ...

  3. bzoj1513【POI2006】Tet-Tetris 3D

    1513: [POI2006]Tet-Tetris 3D Time Limit: 30 Sec  Memory Limit: 162 MB Submit: 733  Solved: 245 [Subm ...

  4. 模拟 - BZOJ 1510 [POI2006] Kra-The Disks

    BZOJ 1510 [POI2006] Kra-The Disks 描述 Johnny 在生日时收到了一件特殊的礼物,这件礼物由一个奇形怪状的管子和一些盘子组成. 这个管子是由许多不同直径的圆筒(直径 ...

  5. 【BZOJ】1513: [POI2006]Tet-Tetris 3D

    题意 给\(n(1 \le n \le 20000)\)个立方体\((x, y, z)\),依次落下.求所有立方体落下完了以后最高的高度. 分析 平面求最大值,平面更新最大值. 题解 二维线段树走起, ...

  6. bzoj 1510 [POI2006]Kra-The Disks 二分

    1510: [POI2006]Kra-The Disks Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 466  Solved: 272[Submit][ ...

  7. bzoj 1520 [POI2006]Szk-Schools 费用流

    [POI2006]Szk-Schools Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 743  Solved: 381[Submit][Status][ ...

  8. bzoj 1517 [POI2006]Met 贪心

    [POI2006]Met Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 203  Solved: 108[Submit][Status][Discus ...

  9. BZOJ 1511: [POI2006]OKR-Periods of Words

    Description 求一个最长周期. Sol KMP. 一个点的最短周期就是 \(i-next[i]\) 此外 \(i-next[next[i]],i-next[next[next[i]]]\) ...

随机推荐

  1. 夺命雷公狗ThinkPHP项目之----企业网站3之后台栏目页的搭建(百度编辑器的引入)

    我们现在就开始搭建我们的后台栏目页的后台了: 首先创建一个CategoryController.class.php的控制器,让列表页和添加页面显示出来先: 然后就是开始动手修改我们的视图部分了: 我们 ...

  2. linux时区的设置

    到目前为止,个人的理解就是linux中设置时区就是修改配置文件 /etc/localtime 而通常的做法就是让这个文件作为符号链接,链接到 /usr/share/zoneinfo/ 中的某个特定的时 ...

  3. ASP.NET MVC WebApi 返回数据类型序列化控制(json,xml)

    我们都知道在使用WebApi的时候Controller会自动将Action的返回值自动进行各种序列化处理(序列化为json,xml等),但是如果Controller的自动序列化后的结果不是我们想要的该 ...

  4. Openstack的用户登录流程

    openstack的用户登录,需要获得集中权限. token 只需要提供用户名和密码即可获得,接口 http://public_url/tokens method:POST body:{"a ...

  5. JAVA 集合List,数组,Set,Map,直接的相互转换

    Java集合转换[List<-->数组.List<-->Set.数组<-->Set.Map-->Set.Map-->List] //List--> ...

  6. LAMP php5.4编译

    编译时出现下列问题时: In file included from /usr/local/src/php-5.4.6/ext/gd/gd.c:103: /usr/local/src/php-5.4.6 ...

  7. linux异步通信之epoll【转】

    转自:http://www.cnblogs.com/snake-hand/archive/2012/08/13/2636229.html 1.简介 epoll是linux提供的一种异步的I/O通知方式 ...

  8. fflush函数的深入理解

    本人昵称sky,欢迎与各位多多交流学习 这样的c程序想必大家都不陌生,fflush()这个函数有清除输入输出缓存的功能,那很多人就会问了,什么是清除输入输出缓存呢? 其实就是我们在printf输出的时 ...

  9. HDU 1498:50 years, 50 colors(二分图匹配)

    http://acm.hdu.edu.cn/showproblem.php?pid=1498 题意:给出一个 n*n 的矩阵,里面的数字代表一种颜色,每次能炸掉一排或者一列的相同颜色的气球,问有哪些颜 ...

  10. 通达OA 免狗迁移到公网 的另类解决办法

    1,通达OA 发布到公网 ,要真正的 Anywhere2,正版通达OA,有加密狗在本地机器上 ,通达必须检测有狗才可以运行3,阿里云服务器  (你想往上插加密狗都没地方的说..汗)4,本地ISP 不提 ...