#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
const int N=110;
char g[N][N];
int n,m;
int bx,by,X,Y;
int bfs()
{
int ans=-0x3f;
queue<PII> Q;
Q.push({bx,by});
int dist[N][N];
memset(dist,-1,sizeof dist);
dist[bx][by]=0;
int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
while(!Q.empty())
{
PII t=Q.front();Q.pop();
for(int i=0;i<8;i++)
{
int a=t.x+dx[i],b=t.y+dy[i];
if(a>0&&a<=n&&b<=m&&b>0&&g[a][b]!='*'&&dist[a][b]==-1)
{
dist[a][b]=dist[t.x][t.y]+1;
ans=max(dist[a][b],ans);
Q.push({a,b});
}
}
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin>>m>>n>>X>>Y;
bx=n+1-Y,by=X;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>g[i][j];
cout<<bfs()<<endl;
return 0;
}
大佬 为啥 要设bx和by呢
begin X 坐标,begin Y 坐标
谢谢大佬