ZOJ Monthly, February 2012 - H Matrix (ZOJ 3578)
开始看到这题以为是二维线段树,但是二维的线段树从来没写过也不知道怎么写,昨天晚上突来灵感,可以用复杂度为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)相关推荐
- 思维+multiset ZOJ Monthly, July 2015 - H Twelves Monkeys
题目传送门 1 /* 2 题意:n个时刻点,m次时光穿梭,告诉的起点和终点,q次询问,每次询问t时刻t之前有多少时刻点是可以通过两种不同的路径到达 3 思维:对于当前p时间,从现在到未来穿越到过去的是 ...
- ZOJ Monthly,Feburary 2012 部分题解
题目链接:点击打开链接 ZOJ 3573 Under Attack 距离做这套题到写题解间隔比较久,题意有些忘了.. #include <iostream> #include <cs ...
- ZOJ Monthly, November 2012
A.ZOJ 3666 Alice and Bob 组合博弈,SG函数应用 #include<vector> #include<cstdio> #include<cstri ...
- ZOJ Monthly, August 2012 题解
A: 题目链接:点击打开链接 Alice's present #include <cstdio> #include <iostream> #include <cstrin ...
- 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 ...
- ZOJ Monthly, August 2012
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=340 A Alice's present 题意:给出一个10 ...
- ZOJ Monthly, June 2014 月赛BCDEFGH题题解
比赛链接:点击打开链接 上来先搞了f.c,,然后发现状态不正确,一下午都是脑洞大开,, 无脑wa,无脑ce...一样的错犯2次.. 硬着头皮搞了几发,最后20分钟码了一下G,不知道为什么把1直接当成不 ...
- 记次浙大月赛 134 - ZOJ Monthly, June 2014
链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类 ...
- ZOJ 3988 2017CCPC秦皇岛 H:Prime Set(二分匹配)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3988 题意: 给你n个数,如果{i, j}满足i!=j & ...
最新文章
- 机器学习与数据挖掘网上资源搜罗——良心推荐
- Dicom 学习笔记-Dicom 消息服务(DIMSE-C/DIMSE-N)
- 逗号操作符以及(0,function)()
- sklearn线性回归
- python matlabplot animate 刷新_matlab动态绘图Animation
- 【Linux系统编程】vfork() 函数详解
- json数据格式 穗康码_Json数据格式
- 2月5日年初六返沪的情景
- idea 启动tomcat 工程_如何在IDEA中创建web项目并且部署到Tomcat中
- 程序驱动防止消息钩子入侵
- appscan 历史版本下载
- Axure原型设计说明
- chrome 打开默认页 被篡改_Chrome谷歌浏览器主页总被篡改怎么解决?
- 惠普HP Laser MFP 137fnw 一体机驱动
- 膝关节前交叉韧带重建术后取钉记
- 数据库中的锁机制(数据库中有哪些锁)
- Autojs在线云更新教程
- 三色视者与四色视者身后的理论基础:色彩原理
- Refactor this method to reduce its Cognitive Complexity from 65 to the 15 allowed. [+22 locations]
- Weka Explorer(探索者界面) 详解(1)