rt,代码:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool vis[N][N];
char g[N][N];
int n, m;
struct mzS { int x, y; }; queue <mzS> mq;
string BFS_mz ()
{
mq.push ({1, 1});
vis[1][1] = true;
while (mq.size ())
{
auto now = mq.front (); mq.pop ();
if (now.x == n && now.y == m) return "Yes";
for (int i = 0; i < 4; i ++)
{
int nx = now.x + dx[i];
int ny = now.y + dy[i];
if (nx < 0 || ny < 0 || nx > n || ny > m) continue;
if (vis[nx][ny] || g[nx][ny] == '#') continue;
mq.push ({nx, ny});
}
}
return "No";
}
int main ()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++) cin >> g[i][j];
cout << BFS_mz ();
return 0;
}