#include #include #include #include using namespace std; int main() { int h, w; cin >> h >> w; vector s(h); int blackCount = 0; for (int i = 0; i < h; ++i) { cin >> s[i]; blackCount += count(s[i].begin(), s[i].end(), '#'); } if (blackCount == 0) { cout << "NO" << endl; return 0; } vector filled(h); for (int offsetY = 0; offsetY < h; ++offsetY) { for (int offsetX = 0; offsetX < w; ++offsetX) { if (offsetX == 0 && offsetY == 0) { continue; } filled.assign(s.begin(), s.end()); bool possible = true; for (int y = 0; y < h && possible; ++y) { for (int x = 0; x < w && possible; ++x) { if (filled[y][x] == '#') { if ((x + offsetX < w) && (y + offsetY < h) && (filled[y + offsetY][x + offsetX] == '#')) { filled[y][x] = 'R'; filled[y + offsetY][x + offsetX] = 'B'; } else { possible = false; } } } } if (possible) { cout << "YES" << endl; return 0; } } } for (int offsetY = 0; offsetY < h; ++offsetY) { for (int offsetX = 0; offsetX > -w; --offsetX) { if (offsetX == 0 && offsetY == 0) { continue; } filled.assign(s.begin(), s.end()); bool possible = true; for (int y = 0; y < h && possible; ++y) { for (int x = w - 1; x >= 0 && possible; --x) { if (filled[y][x] == '#') { if ((x + offsetX >= 0) && (y + offsetY < h) && (filled[y + offsetY][x + offsetX] == '#')) { filled[y][x] = 'R'; filled[y + offsetY][x + offsetX] = 'B'; } else { possible = false; } } } } if (possible) { cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; }