#include #include #include #include //#include #include #include #include #include #include //#include #include #include #include //#include #include #include //#include #include #include #include const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; typedef complex C; const int MAXN = 104; string field[MAXN]; bool used[MAXN][MAXN]; int N, M; int lasty, lastx, lastdir; bool outOfRange(int y, int x) { return (y < 0 || y >= N || x < 0 || x >= M); } void dfs(int y, int x, int dir, int flag) { lasty = y; lastx = x; lastdir = dir; used[y][x] = true; int ny = y+dy[dir]; int nx = x+dx[dir]; if (outOfRange(ny, nx) || field[ny][nx] == '#' || used[ny][nx]) { dir += (flag == 0) ? 1 : 3; dir %= 4; ny = y+dy[dir]; nx = x+dx[dir]; if (outOfRange(ny, nx) || field[ny][nx] == '#') return; if (used[ny][nx]) return; dfs(ny, nx, dir, flag); return; } dfs(ny, nx, dir, flag); } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; for (int i = 0; i < N; i++) cin >> field[i]; for (int y = 0; y < N; y++) for (int x = 0; x < M; x++) { if (field[y][x] == '#') continue; for (int k = 0; k < 4; k++) { for (int flag = 0; flag < 2; flag++) { memset(used, false, sizeof(used)); dfs(y, x, k, flag); bool ng = false; for (int i = 0; i < N; i++) { if (ng) break; for (int j = 0; j < M; j++) { if (field[i][j] != '#' && !used[i][j]) { ng = true; break; } } } if (!ng) { if (lasty+dy[lastdir] == y && lastx+dx[lastdir] == x) { cout << "YES" << endl; return 0; } int dirdir = lastdir; dirdir += (flag == 0) ? 1 : 3; dirdir %= 4; if (lasty+dy[dirdir] == y && lastx+dx[dirdir] == x) { cout << "YES" << endl; return 0; } } } } } cout << "NO" << endl; return 0; }