#include<bits/stdc++.h>
using namespace std;
char aa;
int a[101][101];
int n,m;
int f[4][2]={1,0,-1,0,0,1,0,-1};
struct s{
int x;
int y;
}no,ne;
bool bfs(){
no.x=0;
no.y=0;
queue<s>q;
q.push(no);
while(q.empty()==false){
//cout<<"-----"<<endl;
no=q.front();
q.pop();
int xx,yy;
for(int i=0;i<4;i++){
xx=no.x+f[i][0];
yy=no.y+f[i][1];
if(xx>=0&&xx<n&&yy>=0&&yy<m&&a[xx][yy]!=1){
ne.x=xx;
ne.y=yy;
if(xx==n-1&&yy==m-1){
return true;
}
q.push(ne);
}
}
}
return false;
}
int main(){
cin>>n>>m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>aa;
if(aa=='.'){
a[i][j]==0;
}
if(aa=='#'){
a[i][j]==1;
}
}
}
bool ans=bfs();
if(ans==true){
cout<<"Yes";
}
else{
cout<<"No";
}
return 0;
}
样例过了,全MLE,发生甚吗事儿了??