水题。好久没有写过优化搜索题了。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
char str[][];
int r[][];
int c[][];
int judge(int rx,int ry,int lx,int ly)
{
int i,j;
for(i = lx;i <= rx;i ++)
{
for(j = ly;j <= ry;j ++)
{
if(str[i-][j-] == '')
return ;
}
}
return ;
}
int main()
{
int n,m,i,j,k,u,ans;
scanf("%d%d",&n,&m);
for(i = ;i < n;i ++)
scanf("%s",str[i]);
ans = ;
for(i = ;i <= n;i ++)
{
for(j = ;j <= m;j ++)
{
if(str[i-][j-] == '')
{
r[i][j] = r[i-][j] + ;
c[i][j] = c[i][j-] + ;
}
else
{
r[i][j] = ;
c[i][j] = ;
}
}
}
for(i = n;i >= ;i --)
{
for(j = m;j >= ;j --)
{
for(k = ;k <= r[i][j];k ++)
{
for(u = ;u <= c[i][j];u ++)
{
if(ans >= (k+u)*) continue;
if(judge(i,j,i-k+,j-u+))
{
ans = max(ans,(k+u)*);
}
}
}
}
}
printf("%d\n",ans);
return ;
}