hiahia @ 2018-07-25 17:03:28
#include<bits/stdc++.h>
using namespace std;
int f[2505][2505];
int n,m;
int gao[2505];
int leftt[2505];
int q;
int ans;
int rightt[2505];
int mapp[2505][2505];
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
cin>>q;
mapp[i][j]=q;
if(q==0)
{
gao[j]=gao[j]+1;
leftt[j]=leftt[j-1]+1;
}
if(q==1)
{
f[i][j]=min(f[i-1][j-1]+1,min(gao[j]+1,leftt[j-1]+1));
gao[j]=0;
leftt[j]=0;
ans=max(ans,f[i][j]);
}
}
memset(gao,0,sizeof(gao));
memset(f,0,sizeof(f));
for(int i=1;i<=n;i++)
for(int j=n;j>=1;j--)
{
if(mapp[i][j]==0)
{
gao[j]=gao[j]+1;
rightt[j]=rightt[j+1]+1;
}
if(mapp[i][j]==1)
{
f[i][j]=min(f[i-1][j+1]+1,min(gao[j]+1,rightt[j+1]+1));
gao[j]=0;
rightt[j]=0;
ans=max(ans,f[i][j]);
}
}
cout<<ans;
}