rt
陷入无限递归
#include<bits/stdc++.h>
using namespace std;
char c[105][105];
int n,m;
bool dfs(int x,int y){
if(c[x][y] == '#'){
return false;
}
if(x == n && y == m){
return true;
}
if(x < 1 || y < 1 || x > n || y > m){
return false;
}
bool u = dfs(x-1,y),l = dfs(x,y-1),r = dfs(x,y+1),d = dfs(x+1,y);
bool res = u || l || r || d;
return res;
}
int main(){
cin>>n>>m;
for(int i = 1;i <= n;i ++){
for(int j = 1;j <= m;j ++){
cin>>c[i][j];
}
}
bool tmpv = dfs(1,1);
tmpv?cout<<"Yes":cout<<"No";
}