BZOJ 1057: [ZJOI2007]棋盘制作
2014-08-31 15:59
330 查看
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1057
水题,不解释.
代码:
水题,不解释.
代码:
#include <iostream> #include <cstdio> #include <cstring> #include <string.h> #include <queue> #include <vector> #include <algorithm> #include <cassert> #include <set> #include <map> #include <cmath> #include <ctime> using namespace std; #define rep(i,a,b) for(int i=(a);i<(b);++i) #define rrep(i,a,b) for(int i=(a);i>=(b);--i) #define clr(a,x) memset(a,(x),sizeof(a)) #define eps 1e-8 #define LL long long #define mp make_pair const int maxn=2000+5; int h[maxn],l[maxn],r[maxn]; int a[maxn][maxn]; void read_int(int & x) { char ch=getchar(); while(ch<'0'||ch>'9') ch=getchar(); x=ch-'0'; ch=getchar(); while('0'<=ch&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); } } int main() { // freopen("in.txt","r",stdin); int n,m; while(scanf("%d%d",&n,&m)==2) { rep(i,1,n+1) rep(j,1,m+1) read_int(a[i][j]); int square=0,rect=0; clr(h,0); rep(i,1,n+1) { rep(j,1,m+1) if(a[i][j]!=a[i-1][j]) ++h[j]; else h[j]=1; rep(j,1,m+1) l[j]=r[j]=j; rep(j,2,m+1) while(l[j]-1>=1&&h[l[j]-1]>=h[j]&&a[i][l[j]-1]!=a[i][l[j]]) l[j]=l[l[j]-1]; rrep(j,m-1,1) while(r[j]+1<=m&&h[r[j]+1]>=h[j]&&a[i][r[j]+1]!=a[i][r[j]]) r[j]=r[r[j]+1]; rep(j,1,m+1) { square=max(square,min(h[j],r[j]-l[j]+1)*min(h[j],r[j]-l[j]+1)); rect=max(rect,h[j]*(r[j]-l[j]+1)); } } printf("%d\n%d\n",square,rect); } }
相关文章推荐
- BZOJ1057 [ZJOI2007]棋盘制作 【最大同色矩形】
- 【LuoguP1169 bzoj1057】[ZJOI2007]棋盘制作
- BZOJ 1057: [ZJOI2007]棋盘制作
- 1057: [ZJOI2007]棋盘制作 - BZOJ
- [BZOJ1057]ZJOI2007棋盘制作|DP|单调栈
- 【BZOJ1057】[ZJOI2007]棋盘制作【最大全0子矩阵】【单调栈】【悬链法】
- [BZOJ]1057: [ZJOI2007]棋盘制作 悬线法求最大子矩阵
- BZOJ1057 [ZJOI2007]棋盘制作
- [BZOJ]1057: [ZJOI2007]棋盘制作
- bzoj1057 [ZJOI2007]棋盘制作
- bzoj1057: [ZJOI2007]棋盘制作(Dp)
- bzoj 1057: [ZJOI2007]棋盘制作 求最大全0/1矩阵(极大扩展矩阵)动态规划
- BZOJ 1057 ZJOI2007 棋盘制作 单调栈
- 【BZOJ 1057】 [ZJOI2007]棋盘制作
- bzoj 1057: [ZJOI2007]棋盘制作 (dp+悬线法)
- BZOJ1057[ZJOI2007]棋盘制作 [单调栈]
- bzoj 1057: [ZJOI2007]棋盘制作 单调栈
- [BZOJ1057][ZJOI2007]棋盘制作 单调栈
- BZOJ1057:[ZJOI2007]棋盘制作——题解
- BZOJ1057: [ZJOI2007]棋盘制作