POJ 3494 Largest Submatrix of All 1’s Description Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements. Input The input contains multiple test cases. Each tes…
Largest Submatrix of All 1’s Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements. Input The input contains multiple test cases. Each test case begins with m …
题目链接:http://poj.org/problem?id=3494 题意:给出一个01的矩阵,找出一个面积最大的全1矩阵. 思路:用h[i][j]表示从位置(i,j)向上连续1的最大长度.之后枚举每一行.对于某行,对于该行的每列,预处理left[j]和right[j],left[j]表示j列向左可以到达的最左位置使得[left[j],j]的所有列的h值均大于等于h[i][j],right类似.之后枚举列,用(right[j]-left[j]+1)*h[i][j]更新答案. int a[N][…
POJ 2796 Feel Good HDU 1506 Largest Rectangle in a Histogram 和这两题一样的方法. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; +; int a[maxn]; int L[maxn],R[maxn]; int m,n; int tmp[maxn][maxn],b…
[题目链接] http://poj.org/problem?id=3494 [题目大意] 在01矩阵中求最大全1子矩形 [题解] 在处理每个点的时候,继承上一个点等高度下的左右最大扩展, 计算在该层的左右最大扩展,然后对于每个点更新答案即可. [代码] #include <cstdio> #include <cstring> using namespace std; const int N=2010; int i,j,n,m,ans,l[N],r[N],h[N],lmax,rmax…
题目链接:http://poj.org/problem?id=3494 题目大意: 出1个M*N的矩阵M1,里面的元素只有0或1,找出M1的一个子矩阵M2,M2中的元素只有1,并且M2的面积是最大的.输出M2的面积   解题思路: 枚举以当前位置为真实高度,查找它的左右边界,更新答案.   代码: #include<iostream> #include<cstdio> #include<cstring> using namespace std; typedef long…
Largest Rectangle in a Histogram http://poj.org/problem?id=2559 题意:给出若干宽度相同的矩形的高度(条形统计图),求最大子矩形面积 解题思路 单调栈的经典题(嫌弃字多可以先看后面的示例再来看这个思路) 显然,最终的子矩形高度一定和某一个矩形相等(反证).因此一个暴力的做法就是枚举每一个矩形,然后往两边扩散.在它左侧找到第一个高度比它小的,右侧也一样.则可以求出最大可扩散宽度,乘上高度即可以更新答案.复杂度O(n2) 如果说要优化刚才…
Largest Submatrix of All 1’s Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 8551   Accepted: 3089 Case Time Limit: 2000MS Description Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we me…
Largest Submatrix of All 1’s Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 9512   Accepted: 3406 Case Time Limit: 2000MS Description Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we me…
Largest Submatrix Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2018    Accepted Submission(s): 967 Problem Description Now here is a matrix with letter 'a','b','c','w','x','y','z' and you ca…