2024yhy @ 2024-04-27 18:10:17
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
char a[200][200];
bool v[200][200];
void dfs(int x,int y)
{
if(x==n&&y==m)
{
cout<<"Yes";
exit(0);
}
for(int i=0;i<4;i++)
{
int xx=x+dx[i],yy=y+dy[i];
if(xx>n||yy>m||xx<1||yy<1||a[xx][yy]=='#'||v[xx][yy]==true) continue;
else
{
v[xx][yy]=true;
dfs(xx,yy);
}
}
return ;
}
signed main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>' '+a[i];
if(a[1][2]=='#'&&a[2][1]=='#')
{
cout<<"No";
return 0;
}
dfs(1,1);
cout<<"No";
return 0;
}
by Ghost_2025 @ 2024-05-03 18:54:45
%%%