|
沙发
楼主 |
发表于 2018-9-30 16:30:26
|
只看该作者
- #include<iostream>
- #include<cstring>
- #define FOR(i,a,b) for(int i=a;i<=b;i++)
- #define ROF(i,a,b) for(int i=a;i>=b;i--)
- using namespace std;
- const int N=2550;
- int n,m,f[N][N],s1[N][N],s2[N][N],ans;
- bool map[N][N];
- int main()
- {
- cin>>n>>m;
- FOR(i,1,n)FOR(j,1,m)
- {
- cin>>map[i][j];
- if(!map[i][j])
- {
- s1[i][j]=s1[i][j-1]+1;
- s2[i][j]=s2[i-1][j]+1;
- }
- else
- f[i][j]=min(f[i-1][j-1],min(s1[i][j-1],s2[i-1][j]))+1;
- ans=max(ans,f[i][j]);
- }
- memset(f,0,sizeof(f));memset(s1,0,sizeof(s1));
- FOR(i,1,n)ROF(j,m,1)
- {
- if(!map[i][j])s1[i][j]=s1[i][j+1]+1;
- else f[i][j]=min(f[i-1][j+1],min(s1[i][j+1],s2[i-1][j]))+1;
- ans=max(ans,f[i][j]);
- }
- cout<<ans<<endl;
- return 0;
- }
复制代码 |
|