#include #include using namespace std; int dy[] = {1, 0, -1, 0}; int dx[] = {0, -1, 0, 1}; int H, W; string mat[111]; char at(int y, int x){ if(y < 0 || y >= H || x < 0 || x >= W)return '#'; return mat[y][x]; } bool used[111][111]; bool check(int sy, int sx, int rest, int y, int x, int d){ if(used[y][x]){ if(y == sy && x == sx && rest == 0){ return true; } else { return false; } } used[y][x] = true; for(int i=0;i<2;i++){ int ny = y + dy[d]; int nx = x + dx[d]; if(at(ny, nx) == '.'){ return check(sy, sx, rest - 1, ny, nx, d); } d = (d + 1) % 4; } return false; } string solve(){ int dot = 0; for(int y=0;y max_dot)return "NO"; for(int sy=0;sy> H >> W; for(int i=0;i> mat[i]; cout << solve() << endl; return 0; }