zafa2023 @ 2024-07-16 13:10:54
#include<bits/stdc++.h>
using namespace std;
char x[101][101];
int x2[101][101]={};
bool iffi=0;
void bds(int x1,int y,int n,int m){
if(x[x1][y]=='#')
{
return ;
}
else if(x1==m&&y==n&&iffi==0)
{
cout<<"Yes";
iffi=1;
return;
}
x2[x1][y]=1;
if(x1!=1&&x2[x1-1][y]==0)
{
bds(x1-1,y,n,m);
}
if(y!=1&&x2[x1][y-1]==0)
{
bds(x1,y-1,n,m);
}
if(x1!=n&&x2[x1+1][y]==0)bds(x1+1,y,n,m);
if(y!=n&&x2[x1][y+1]==0)bds(x1,y+1,n,m);
}
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int i1=1;i1<=m;i1++)
{
cin>>x[i][i1];
}
}
bds(1,1,m,n);
if(iffi==0)cout<<"No";
return 0;
}