Matrix


Time Limit: 10 Seconds      Memory Limit: 131072 KB

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, aibihixiyi (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)的更多相关文章

  1. angular2系列教程(十一)路由嵌套、路由生命周期、matrix URL notation

    今天我们要讲的是ng2的路由的第二部分,包括路由嵌套.路由生命周期等知识点. 例子 例子仍然是上节课的例子:

  2. 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 ...

  3. Atitit Data Matrix dm码的原理与特点

    Atitit Data Matrix dm码的原理与特点 Datamatrix原名Datacode,由美国国际资料公司(International Data Matrix, 简称ID Matrix)于 ...

  4. Android笔记——Matrix

    转自:http://www.cnblogs.com/qiengo/archive/2012/06/30/2570874.html#translate Matrix的数学原理 在Android中,如果你 ...

  5. 通过Matrix进行二维图形仿射变换

    Affine Transformation是一种二维坐标到二维坐标之间的线性变换,保持二维图形的"平直性"和"平行性".仿射变换可以通过一系列的原子变换的复合来 ...

  6. [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 ...

  7. [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 ...

  8. [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 ...

  9. [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 ...

随机推荐

  1. UVa10815.Andy's First Dictionary

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  2. postGreSQL数据库部署及简单使用

    1,deployByRuiyIns rpm -ivh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.no ...

  3. 【转】Windows与Linux(Ubuntu)双系统时间不一致的解决方法

    当在嵌入式Linux里面备份文件时候,在备份的时候,PC(win7)和开发板的时间都是9:30,但是在开发板发现文件创建时间是9:30,然后u盘插在PC(win7)上,发现文件创建时间是1:30,为什 ...

  4. Unity Navigation自动寻路

    NavMesh(导航网格) 是3D游戏世界中主动寻路的一种技术,如果你想让游戏人物能自动绕开障碍物到达目的地.那你就来学习下 Navigation导航技术吧O(∩_∩)O~ 首先创建一个项目创建Pan ...

  5. ios 读取通讯录数据

    #import <Foundation/Foundation.h> @interface LoadingContactData : NSObject // 读取通讯录 + (Loading ...

  6. Oracle与DB2的区别

    系统结构概述 首先,我们需要理解 Oracle 使用的架构,并理解它与 DB2 的不同之处.图 1 展示了 Oracle 的系统结构.将该图与 图 2 进行比较,后者显示了 DB2 的系统结构.在阅读 ...

  7. 33c3-pwn350-tea

    TEA 感觉这个题目出得很不错.先运行程序了解基本功能,程序可以读取对系统上存在的文件的内容,如果文件不存在的话,直接退出. 使用IDA打开后,发现父进程通过clone api克隆出一个子进程,主要的 ...

  8. 图片轮播插件 Slides-SlidesJS-3

    图片轮播插件  Slides-SlidesJS-3 demo document 地址: http://slidesjs.com/

  9. html链接

    1. <a href="/index.html">本文本</a> 是一个指向本网站中的一个页面的链接.</p><p><a hr ...

  10. Sigmoid function in NN

    X = [ones(m, ) X]; temp = X * Theta1'; t = size(temp, ); temp = [ones(t, ) temp]; h = temp * Theta2' ...