#include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { int h, w; cin >> h >> w; vector s(h); for (string& s_i : s) cin >> s_i; vector d1(h, vector(w, 0)); REP(diag, h + w - 1) { for (auto [y, x] = (diag < w ? make_pair(0, diag) : make_pair(diag - (w - 1), w - 1)); y < h && x >= 0;) { if (s[y][x] == '.') { ++y; --x; } else { int k = 1; while (y + k < h && x - k >= 0 && s[y + k][x - k] == '#') ++k; REP(i, k) d1[y + i][x - i] = min(i + 1, k - i); y += k; x -= k; } } } vector d2(h, vector(w, 0)); REP(diag, h + w - 1) { for (auto [y, x] = (diag < h ? make_pair(diag, 0) : make_pair(0, diag - (h - 1))); y < h && x < w;) { if (s[y][x] == '.') { ++y; ++x; } else { int k = 1; while (y + k < h && x + k < w && s[y + k][x + k] == '#') ++k; REP(i, k) d2[y + i][x + i] = min(i + 1, k - i); y += k; x += k; } } } // REP(i, h) REP(j, w) cout << d1[i][j] << " \n"[j + 1 == w]; // cout << '\n'; // REP(i, h) REP(j, w) cout << d2[i][j] << " \n"[j + 1 == w]; vector nd1(h, vector(w, 0)), nd2(h, vector(w, 0)); REP(i, h) REP(j, w) { const int l = min(d1[i][j], d2[i][j]); if (l >= 2) { nd1[i - l + 1][j + l - 1] = max(nd1[i - l + 1][j + l - 1], l * 2 - 1); nd2[i - l + 1][j - l + 1] = max(nd2[i - l + 1][j - l + 1], l * 2 - 1); } } // REP(i, h) REP(j, w) cout << nd1[i][j] << " \n"[j + 1 == w]; // cout << '\n'; // REP(i, h) REP(j, w) cout << nd2[i][j] << " \n"[j + 1 == w]; vector is_painted(h, vector(w, 0)); REP(diag, h + w - 1) { int l = 0; for (auto [y, x] = (diag < w ? make_pair(0, diag) : make_pair(diag - (w - 1), w - 1)); y < h && x >= 0; ++y, --x) { l = max(l - 1, nd1[y][x]); if (l > 0) is_painted[y][x] = true; } } REP(diag, h + w - 1) { int l = 0; for (auto [y, x] = (diag < h ? make_pair(diag, 0) : make_pair(0, diag - (h - 1))); y < h && x < w; ++y, ++x) { l = max(l - 1, nd2[y][x]); if (l > 0) is_painted[y][x] = true; } } REP(i, h) REP(j, w) { if (s[i][j] == '#' && !is_painted[i][j]) { cout << "No\n"; return 0; } } cout << "Yes\n"; return 0; }