#include void solve() { int h, w; std::cin >> h >> w; std::vector s(h); for (int i = 0; i < h; i++) std::cin >> s[i]; const int n = h + w - 1; std::vector>> naname1(h + w - 1); std::vector>> naname2(h + w - 1); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (s[i][j] == '#') { naname1[i + j].emplace_back(i, j); naname2[i + w - j - 1].emplace_back(i, j); } } } const int INF = 1e9; std::vector a(h, std::vector(w, INF)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (s[i][j] == '.') a[i][j] = 0; } } for (int k = 0; k < n; k++) { for (int l = 0; l < (int)naname1[k].size();) { int r = l + 1; while (r < (int)naname1[k].size() && naname1[k][r - 1].first + 1 == naname1[k][r].first) r++; int len = r - l; for (int c = 0; c < len; c++) { auto [i, j] = naname1[k][l + c]; a[i][j] = std::min({a[i][j], c, len - c - 1}); } l = r; } } for (int k = 0; k < n; k++) { for (int l = 0; l < (int)naname2[k].size();) { int r = l + 1; while (r < (int)naname2[k].size() && naname2[k][r - 1].first + 1 == naname2[k][r].first) r++; int len = r - l; for (int c = 0; c < len; c++) { auto [i, j] = naname2[k][l + c]; a[i][j] = std::min({a[i][j], c, len - c - 1}); } l = r; } } const int DI[] = {1, 1, -1, -1}; const int DJ[] = {1, -1, 1, -1}; std::priority_queue> que; std::vector ans(h, std::vector(w, std::vector(4))); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (a[i][j] != 0) { for (int k = 0; k < 4; k++) { ans[i][j][k] = a[i][j]; que.emplace(a[i][j], i, j, k); } } } } while (!que.empty()) { auto [d, i, j, k] = que.top(); que.pop(); if (ans[i][j][k] > d) continue; int ni = i + DI[k]; int nj = j + DJ[k]; if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue; if (ans[ni][nj][k] < d - 1) { ans[ni][nj][k] = d - 1; que.emplace(ans[ni][nj][k], ni, nj, k); } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { bool ok = false; for (int k = 0; k < 4; k++) { if (ans[i][j][k] > 0) { ok = true; } } if (s[i][j] == '#' && !ok) { std::cout << "No" << '\n'; return; } } } std::cout << "Yes" << '\n'; } int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(16); int t = 1; while (t--) solve(); }