我的错误代码:
#include<bits/stdc++.h>
using namespace std;
int n;
string a[1001];
int b,c,d,e;
bool g;
int dfs(int x,int y){
if(x<0 or x>n or y<0 or y>n or a[x][y]=='#') return 0;
if(x==d and y==e) g=true;
a[x][y]='#';
dfs(x-1,y);
dfs(x+1,y);
dfs(x,y-1);
dfs(x,y+1);
}
int main(){
int k;
cin>>k;
for(int i=0;i<k;i++){
g=false;
cin>>n;
for(int x=0;x<n;x++){
cin>>a[x];
}
cin>>b>>c>>d>>e;
if(a[b][c]=='#' or a[e][d]=='#'){
cout<<"NO"<<endl;
goto f;
}
dfs(b,c);
if(g==1)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
f:{}
}
return 0;
}