开始看到这题以为是二维线段树,但是二维的线段树从来没写过也不知道怎么写,昨天晚上突来灵感,可以用复杂度为c2的一个方法,每次比较两个矩阵是否相交,然后更新矩阵的值,速度很快!zoj月赛ac这题的人大部分都是这种方法吧,内存才200k。。。法克,我早该想到!!!

#include<iostream>
#include<vector>
#include<cstring>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cassert>
using namespace std;const int maxn = 1011;struct zz
{int x1,y1;int x2,y2;int h;
}zx[maxn];int x,y,a,b,h;
int n,m,c,temp,ans;bool yes(int i,int j)
{if(zx[i].y2 < zx[j].y1 || zx[i].y1 > zx[j].y2 || zx[i].x2 < zx[j].x1 || zx[i].x1 > zx[j].x2){return false;}return true;
}int main()
{while(scanf("%d%d%d",&n,&m,&c)==3){ans = 0;for(int i=1;i<=c;i++){//   cin>>a>>b>>h>>x>>y;scanf("%d%d%d%d%d",&a,&b,&h,&x,&y);zx[i].x1 = x;zx[i].y1 = y;zx[i].x2 = x + a - 1;zx[i].y2 = y + b - 1;temp = h;for(int j=1;j<i;j++){if(yes(i,j)){if( h + zx[j].h > temp ){temp = h + zx[j].h;}}}zx[i].h = temp;if(temp > ans){ans = temp;}}printf("%d\n",ans);}return 0;
}

ZOJ Monthly, February 2012 - H Matrix (ZOJ 3578)相关推荐

  1. 思维+multiset ZOJ Monthly, July 2015 - H Twelves Monkeys

    题目传送门 1 /* 2 题意:n个时刻点,m次时光穿梭,告诉的起点和终点,q次询问,每次询问t时刻t之前有多少时刻点是可以通过两种不同的路径到达 3 思维:对于当前p时间,从现在到未来穿越到过去的是 ...

  2. ZOJ Monthly,Feburary 2012 部分题解

    题目链接:点击打开链接 ZOJ 3573 Under Attack 距离做这套题到写题解间隔比较久,题意有些忘了.. #include <iostream> #include <cs ...

  3. ZOJ Monthly, November 2012

    A.ZOJ 3666 Alice and Bob 组合博弈,SG函数应用 #include<vector> #include<cstdio> #include<cstri ...

  4. ZOJ Monthly, August 2012 题解

    A: 题目链接:点击打开链接 Alice's present #include <cstdio> #include <iostream> #include <cstrin ...

  5. ZOJ 4535 ZOJ Monthly, October 2011 H

    How Many Sets I Time Limit: 2 Seconds      Memory Limit: 65536 KB Give a set S, |S| = n, then how ma ...

  6. ZOJ Monthly, August 2012

    http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=340 A Alice's present   题意:给出一个10 ...

  7. ZOJ Monthly, June 2014 月赛BCDEFGH题题解

    比赛链接:点击打开链接 上来先搞了f.c,,然后发现状态不正确,一下午都是脑洞大开,, 无脑wa,无脑ce...一样的错犯2次.. 硬着头皮搞了几发,最后20分钟码了一下G,不知道为什么把1直接当成不 ...

  8. 记次浙大月赛 134 - ZOJ Monthly, June 2014

    链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类 ...

  9. ZOJ 3988 2017CCPC秦皇岛 H:Prime Set(二分匹配)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3988 题意: 给你n个数,如果{i, j}满足i!=j & ...

最新文章

  1. 机器学习与数据挖掘网上资源搜罗——良心推荐
  2. Dicom 学习笔记-Dicom 消息服务(DIMSE-C/DIMSE-N)
  3. 逗号操作符以及(0,function)()
  4. sklearn线性回归
  5. python matlabplot animate 刷新_matlab动态绘图Animation
  6. 【Linux系统编程】vfork() 函数详解
  7. json数据格式 穗康码_Json数据格式
  8. 2月5日年初六返沪的情景
  9. idea 启动tomcat 工程_如何在IDEA中创建web项目并且部署到Tomcat中
  10. 程序驱动防止消息钩子入侵
  11. appscan 历史版本下载
  12. Axure原型设计说明
  13. chrome 打开默认页 被篡改_Chrome谷歌浏览器主页总被篡改怎么解决?
  14. 惠普HP Laser MFP 137fnw 一体机驱动
  15. 膝关节前交叉韧带重建术后取钉记
  16. 数据库中的锁机制(数据库中有哪些锁)
  17. Autojs在线云更新教程
  18. 三色视者与四色视者身后的理论基础:色彩原理
  19. Refactor this method to reduce its Cognitive Complexity from 65 to the 15 allowed. [+22 locations]
  20. Weka Explorer(探索者界面) 详解(1)

热门文章

  1. 【基础篇1】JavaScript页面生命周期
  2. MT4跨平台跟单系统的实现方式和技术原理
  3. 3.12 haas506开发教程-example-i2c多设备测试
  4. SSJ集成整合、声明式事务管理
  5. 学好3DsMax建模的 6 个技巧
  6. 英文文献翻译策略:一种解决划词翻译包含换行符的最优策略
  7. 实用函数式 Java (PFJ)简介
  8. qmainwindow 背景充电_Qt学习笔记,QWidget和QMainWindow新认识
  9. CentOS6.5环境 安装Keepalived和高可用服务相关参数说明
  10. tplink路由器 配置 svn,实现在外网就可以访问公司的内网