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 ...
随机推荐
- Inorder Successor in BST 解答
Question Given a binary search tree and a node in it, find the in-order successor of that node in th ...
- [置顶] vi、akw和sed总结
- truncate 、delete与drop三者的异同
相同点: 1.truncate和不带where子句的delete.以及drop都会删除表内的数据. 2.drop.truncate都是DDL语句(数据定义语言),执行后会自动提交. 不同点: 1. t ...
- FZU 2108(dfs模拟,大数取余)
K Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Pr ...
- [每日一题] 11gOCP 1z0-052 :2013-09-4 block header grows............................................A33
转载请注明出处:http://write.blog.csdn.net/postedit/11100311 正确答案是:AD 要理解这道题就要去了解数据块的结构.引用OCPPPT中的一幅图: 从这幅图中 ...
- Linux curses库使用
相信您在网路上一定用过如 tin,elm 等工具, 这些软体有项共同的特色, 即他们能利用上下左右等方向键来控制游标的位置. 除此之外, 这些程式的画面也较为美观. 对Programming 有兴趣 ...
- codevs1009
题目地址:http://codevs.cn/problem/1009/ 分析: [TAG]FLOYD,乘法原理,高精度 [构思] 求可变换数的个数,那么就是组合数学的内容,四个原理的应用: 假如能知道 ...
- swift中的传值
光阴似箭,日月如梭,转眼间学习的旅途已经过了一大半了,忘着自己所敲过的成批的代码,看着自己付出和努力,默默地为自己这几个月的奋斗感到欣慰,不论学习的路途再怎么的艰辛,但是自己还是坚持过来了,回想着以往 ...
- ASP.NET母版与内容页相对路径的问题
1. 图片问题 非常好解决 <img runat="server" src="~/images/ad468x60.gif" alt="" ...
- IOS 手机端搜索硬件设备 --- 物联网
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<errno.h> #i ...