/* -*- coding: utf-8 -*- * * 86.cc: No.86 TVザッピング(2) - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100; const int MAX_M = 100; const int dxs[] = {1, 0, -1, 0}, dys[] = {0, -1, 0, 1}; /* typedef */ /* global variables */ int n, m, cn; string as[MAX_N]; bool used[MAX_N][MAX_M]; /* subroutines */ bool check(int sx, int sy, int di) { memset(used, false, sizeof(used)); int x = sx, y = sy, c = 0; for (;;) { used[y][x] = true; c++; int d; for (d = 0; d < 2; d++) { int di0 = (di + d) & 3; int x0 = x + dxs[di0], y0 = y + dys[di0]; if (x0 >= 0 && x0 < m && y0 >= 0 && y0 < n && as[y0][x0] == '.') { if (x0 == sx && y0 == sy) { //printf(" c=%d, cn=%d\n", c, cn); return (c == cn); } if (! used[y0][x0]) { x = x0, y = y0, di = di0; break; } } } if (d >= 2) return false; } return false; } /* main */ int main() { cin >> n >> m; for (int y = 0; y < n; y++) { cin >> as[y]; for (int x = 0; x < m; x++) if (as[y][x] == '.') cn++; } for (int sy = 0; sy < n; sy++) for (int sx = 0; sx < m; sx++) for (int di = 0; di < 4; di++) if (as[sy][sx] == '.') { bool ans = check(sx, sy, di); //printf("%d,%d,%d = %d\n", sx, sy, di, ans); if (ans) { puts("YES"); return 0; } } puts("NO"); return 0; }