ZOJ3578(Matrix)
Matrix
Time Limit: 10 Seconds Memory Limit: 131072 KB
A N*M coordinate plane ((0, 0)~(n, m)). Initially the value of all N*M grids are 0.
An operation T(a, b, h, x, y) is defined as follow:
1. Select the maximum value in the matrix (x, y) ~ (x+a, y+b), suppose the maximum value is max
2. Change all the value in the matrix (x, y) ~ (x+a, y+b) into max+h
After C operations, please output the maximum value in the whole N*M coordinate.
Input
The input consists of several cases.
For each case, the first line consists of three positive integers N , M and C (N ≤ 1000, M ≤ 1000, C ≤ 1000). In the following C lines, each line consists of 5 non-negative number, ai, bi, hi, xi, yi (0 ≤ hi ≤ 10000, 0 ≤ xi < n, 0 ≤ yi < m).
Output
For each case, output the maximum height.
Sample Input
3 2 2
2 1 9 1 1
1 1 2 2 1
Sample Output
11
感受:判断两个矩阵是否相交,考虑一定不相交的情况。若考虑相交条件则是有可能相交。并且呀,不相交对立面不一定是相交啊(好人的对立面不一定是坏人啊,有可能是不好不坏的人啦,世界并不是由二元性组成的呀!)
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
struct Matrix
{
int x1,x2,y1,y2,maxn;
};
Matrix matrix [+];
bool cover(Matrix a,Matrix b)
{
if(a.x1>=b.x2||b.x1>=a.x2) return false;
if(a.y1>=b.y2||b.y1>=a.y2) return false;
return true;
}
int n,m,c;
int x,y,h,a,b;
int main()
{
while(~scanf("%d%d%d",&n,&m,&c))
{
int ans=; memset(matrix,,sizeof(matrix));
for(int i=;i<c;i++)
{
int temp=;
scanf("%d%d%d%d%d",&a,&b,&h,&x,&y);
matrix[i].x1=x;
matrix[i].x2=x+a;
matrix[i].y1=y;
matrix[i].y2=y+b;
//matrix[i].h=h;
for(int j=;j<i;j++)
{
if(cover(matrix[i],matrix[j]))
temp=max(temp,matrix[j].maxn);
}
matrix[i].maxn=temp+h;
ans=max(ans,matrix[i].maxn);
}
printf("%d\n",ans);
} return ;
} //1 2
//1
//1 5
ZOJ3578(Matrix)的更多相关文章
- angular2系列教程(十一)路由嵌套、路由生命周期、matrix URL notation
今天我们要讲的是ng2的路由的第二部分,包括路由嵌套.路由生命周期等知识点. 例子 例子仍然是上节课的例子:
- Pramp mock interview (4th practice): Matrix Spiral Print
March 16, 2016 Problem statement:Given a 2D array (matrix) named M, print all items of M in a spiral ...
- Atitit Data Matrix dm码的原理与特点
Atitit Data Matrix dm码的原理与特点 Datamatrix原名Datacode,由美国国际资料公司(International Data Matrix, 简称ID Matrix)于 ...
- Android笔记——Matrix
转自:http://www.cnblogs.com/qiengo/archive/2012/06/30/2570874.html#translate Matrix的数学原理 在Android中,如果你 ...
- 通过Matrix进行二维图形仿射变换
Affine Transformation是一种二维坐标到二维坐标之间的线性变换,保持二维图形的"平直性"和"平行性".仿射变换可以通过一系列的原子变换的复合来 ...
- [LeetCode] Kth Smallest Element in a Sorted Matrix 有序矩阵中第K小的元素
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth ...
- [LeetCode] Longest Increasing Path in a Matrix 矩阵中的最长递增路径
Given an integer matrix, find the length of the longest increasing path. From each cell, you can eit ...
- [LeetCode] Search a 2D Matrix II 搜索一个二维矩阵之二
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- [LeetCode] Search a 2D Matrix 搜索一个二维矩阵
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
随机推荐
- HDOJ-1013 Digital Roots
http://acm.hdu.edu.cn/showproblem.php?pid=1013 1.给出一个整数,求每一位上的数字之和 2.若求出的和大于1位,则对该和继续执行第1步,直至和的位数为1 ...
- soj 1700 ping_简单dp
题目链接 题意:给你一个无向图,求n边的最短路 思路:用最短路想了半天都没想出来,比赛结束回去看看原来用dp做,我的dp有待提高啊 sp[i][k]=min(sp[j][k-1]+dp[j][i])/ ...
- DBA 经典面试题(4)
1.如果信息采集管理系统(ICM)崩溃了怎么办? 答案:所有其他的管理器都会继续工作.ICM只会处理队列控制请求,意思是开启和关闭其他并发的管理器. 2.你如何加速打补丁的过程? 答案: ...
- 重载operator new实现检测内存泄漏是否可行
行与不行,就凭我这水平,说出来未免显示太过自大.不还,我还想根据自己的代码来讨论这个问题. 重载operator new来检测内存只的办法,那就是在new的时候记录指针地址及文件名.行号,在delet ...
- 开机后将sim/uim卡上的联系人写入数据库
tyle="margin:20px 0px 0px; font-size:14px; line-height:26px; font-family:Arial; color:rgb(51,51 ...
- Android系统的智能指针(轻量级指针、强指针和弱指针)的实现原理分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6786239 Android 系统的运行时库层代 ...
- Swift——(一)为Swift内置类型加入属性
在看苹果官方的Swift Language的时候,遇到实验:Write an extension for the Double type that add an absoluteValue prope ...
- css-盒模型
<!DOCTYPE html>CSS3-盒模型 盒模型属性: width 宽度 height 高度 margin 外边距 border 边框 padding 内边距.test{width: ...
- jquery 图片比例不变,全屏居中
<!DOCTYPE html> <html> <head> <meta charset="gb2312"> <title> ...
- 检测浏览器是否支持AJAX
<script type="text/javascript"> function ajaxFunction() { var xmlHttp; try { // Fire ...