自己看了亿遍,寻思着也煤油问题啊。。。
#include<bits/stdc++.h>
using namespace std;
int dx[5]={0,0,-1,1},dy[5]={-1,1,0,0};
char a[105][105];
int n,m;
bool bfs(int x,int y){
a[x][y]='#';
if(x==n&&y==m)return true;
for(int i=0;i<4;i++){
int gx=x+dx[i],gy=y+dy[i];
if(a[gx][gy]=='#'||gx<1||gx>n||gy<1||gy>m)continue;
return bfs(gx,gy);
}
return false;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j];
if(bfs(1,1))cout<<"Yes";
else cout<<"No";
return 0;
}