#include<bits/stdc++.h>
using namespace std;
char mp[105][105];
bool vis[105][105];
int dx[4]={0,0,1,-1};
int dy[4]={-1,1,0,0};
int fx,fy,sx,sy,n,c,a=0;
void dfs(int x,int y)
{
if(x==fx&&y==fy)
{
cout<<"YES"<<'\n';
a++;
return;
}
for(int i=0;i<=3;i++)
{
int tx = x+dx[i];
int ty = y+dy[i];
if(tx>=0&&tx<=n&&ty>=0&&ty<=n&&vis[tx][ty]==0&&mp[tx][ty]=='.'){
vis[tx][ty] = 1;
dfs(tx,ty);
}
}
}
int main()
{
scanf("%d",&c);
while(c--)
{
scanf("%d",&n);
a=0;
memset(mp,0,sizeof(mp));
memset(vis,0,sizeof(vis));
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>mp[i][j];
scanf("%d %d %d %d",&sx,&sy,&fx,&fy);
vis[sx][sy]=1;
dfs(sx,sy);
if(mp[sx][sy]=='#'||mp[fx][fy]=='#')
{
cout<<"NO"<<'\n';
continue;
}
if(a==0)
cout<<"NO"<<'\n';
}
return 0;
}
//网址:信息学奥赛一本通(C++版)在线评测系统 (ssoier.cn)
标签:sy,sx,tx,1215,int,迷宫,一本,vis,mp From: https://blog.csdn.net/2403_86776695/article/details/141292051