# BZOJ1057: [ZJOI2007]棋盘制作

3 3
1 0 1
0 1 0
1 0 0

4
6

## HINT

对于100%的数据，N, M ≤ 2000

#include<cstdio>
#include<cctype>
#include<queue>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define ren for(int i=first[x];i!=-1;i=next[i])
using namespace std;
const int BufferSize=1<<16;
inline char Getchar() {
}
}
inline int read() {
int x=0,f=1;char c=getchar();
for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
for(;isdigit(c);c=getchar()) x=x*10+c-'0';
return x*f;
}
const int maxn=2010;
int n,m,A[maxn][maxn],ans1,ans2;
int f[maxn][maxn],left[maxn][maxn],right[maxn][maxn],up[maxn][maxn];
void solve() {
rep(i,1,n) rep(j,1,m) {
if(A[i][j]) f[i][j]=min(min(f[i-1][j],f[i][j-1]),f[i-1][j-1])+1;
else f[i][j]=0;
ans1=max(ans1,f[i][j]);
}
memset(left,0,sizeof(left));
memset(up,0,sizeof(up));
memset(right,0,sizeof(right));
rep(i,1,n) {
int p=0;
rep(j,1,m) if(!A[i][j]) up[i][j]=left[i][j]=0,p=j;
else up[i][j]=up[i-1][j]+1,left[i][j]=i==1?p+1:max(left[i-1][j],p+1);
p=m+1;
dwn(j,m,1) if(!A[i][j]) right[i][j]=m+1,p=j;
else {
right[i][j]=i==1?p-1:min(right[i-1][j],p-1);
ans2=max(ans2,up[i][j]*(right[i][j]-left[i][j]+1));
}
}
}
int main() {
}