#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; #define MOD 1000000007 // 10^9 + 7 #define INF 1000000000 // 10^9 #define LLINF 1LL<<60 bool white[59][59]; int main() { cin.tie(0); ios::sync_with_stdio(false); int H, W; cin >> H >> W; P start; start.first = -1; start.second = -1; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { char c; cin >> c; if (c == '.') white[i][j] = true; if (start.first == -1) { start.first = i; start.second = j; } } } for (int dx = 0; dx <= H - start.first; dx++) { for (int dy = 0; dy <= W - start.second; dy++) { if ((dx>0 || dy > 0)&& !white[start.first + dx][start.second + dy]) { bool field[59][59]; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) field[i][j] = white[i][j]; } bool flag = true; for (int i = 1; i <= H && flag; i++) { for (int j = 1; j <= W && flag; j++) { if (!field[i][j]) { // 元が黒で if (i + dx > H || j + dy > W) flag = false; else { if (field[i + dx][j + dy]) {// 平行移動先が白 flag = false; } else { // 平行移動先も黒 field[i][j] = true; field[i + dx][j + dy] = true; } } } } } if (flag) { cout << "YES" << endl; return 0; } } } } cout << "NO" << endl; return 0; }