zsm____yi @ 2019-03-22 13:17:07
#include <iostream>
#include <fstream>
using namespace std;
int a[2509][2509],f[2509][2509],s[2509][2509];
int l[2509][2509],c[2509][2509];
int ans,ans2;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
scanf("%d",&a[i][j]);
l[i][j]=l[i-1][j]+a[i][j];/*竖直方向前缀和 */
c[i][j]=c[i][j-1]+a[i][j];/* 水平方向前缀和*/
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]){f[i][j]=1;
for(int k=1;k<=f[i-1][j-1];k++){
if(l[i][j]-l[i-k][j]==1 && c[i][j]-c[i][j-k]==1 ){f[i][j]++;}else break;
}
ans=max(ans,f[i][j]);/* 左上角正方形最大*/
s[i][j]=1;
for(int w=1;w<=s[i-1][j+1];w++){
if(l[i][j]-l[i-w][j]==1 && c[i][j+w]-c[i][j]==0 && a[i][j+w]==0){s[i][j]++;}else break;
}
ans2=max(ans2,s[i][j]);/*右上角最大*/
}
}
}
printf("%d",max(ans,ans2));
return 0;
}
by zsm____yi @ 2019-03-22 18:39:16
来人教教我啊