4 3 1 1
....
..*.
.**.
4
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int num,i,j,head,tail,q[1000000],p[1000000],step[1000000];
int x[10]={-1,0,1,0,1,-1,1,-1},y[10]={0,1,0,-1,1,-1,-1,1};
int f[110][110],n,m,s1,s2,ans;
int main()
{
scanf("%d%d%d%d\n",&m,&n,&s1,&s2);
for (i=1;i<=n;i++)
{
char s[110]; gets(s);
for (j=1;j<=m;j++)
if(s[j-1]=='*')
num++,f[i][j]=1;
else
f[i][j]=0;
}
tail++; p[tail]=s2; q[tail]=s1; step[tail]=0; f[s2][s1]=1;
while (head<tail)
{
head++;
for (i=0;i<8;i++)
{
int xl=p[head]+x[i],yl=q[head]+y[i];
if (xl>0&&xl<=n&&yl>0&&yl<=m&&f[xl][yl]==0)
{
f[xl][yl]=1;
tail++; p[tail]=xl; q[tail]=yl; step[tail]=step[head]+1;
ans=max(ans,step[tail]);
}
}
}
printf("%d",ans);
}//flood fill问题 ,这题输入的描述可能有点问题,按正常顺序读入,交换一下n,m; s1,s2