jijiladajiji @ 2024-04-13 18:53:20
#include<bits/stdc++.h>
using namespace std;
int dx[5]={0,1,-1,0,0};
int dy[5]={0,0,0,-1,1};
struct xp{
int x,y;
};
int n,m;
char a[114][514];
void bfs(){
queue<xp>q;
xp sb;
sb.x=1;
sb.y=1;
q.push(sb);
while(!q.empty()){
xp now=q.front();
q.pop();
for(int i=1;i<=4;i++){
int xx=now.x+dx[i];
int yy=now.y+dy[i];
if(xx>=1&& xx<=n && yy>=1 && yy<=m && a[xx][yy]!='#'){
if(xx==n && yy ==m){
cout<<"Yes";
return;
}
xp next;
next.x=xx;
next.y=yy;
q.push(next);
}
}
}
cout<<"No";
return;
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
bfs();
}
by Quartz_Blocks @ 2024-05-06 18:15:00
做个标记
by jijiladajiji @ 2024-08-04 14:50:49
@Quartz_Blocks 感谢