http://www.codeforces.com/problemset/problem/22/B
题意:求出n*m的方格图中全是0的矩阵的最大周长
思路:枚举
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
int n,m,a[][],h[][];
char s[];
int read(){
int t=,f=;char ch=getchar();
while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while (''<=ch&&ch<=''){t=t*+ch-'';ch=getchar();}
return t*f;
}
int main(){
n=read();m=read();
for (int i=;i<=n;i++){
scanf("%s",s+);
for (int j=;j<=m;j++)
a[i][j]=s[j]-'';
}
for (int i=;i<=n;i++)
for (int j=;j<=m;j++){
if (a[i][j]) continue;
if (i!=&&a[i-][j]==) h[i][j]=h[i-][j]+;
else h[i][j]=;
}
int ans=;
for (int i=;i<=n;i++)
for (int j=;j<=m;j++)
if (a[i][j]==)
{
int ll=<<;
for (int k=j;k>=&&a[i][k]==;k--){
ll=std::min(ll,h[i][k]);
ans=std::max(ans,ll+j-k+);
}
}
printf("%d\n",ans*);
return ;
}