#line 2 "/home/shogo314/cpp_include/ou-library/io.hpp" /** * @file io.hpp * @brief 空白区切り出力、iostreamのオーバーロード */ #include #include #include #include #include namespace tuple_io { template std::basic_istream& read_tuple(std::basic_istream& is, Tuple& t) { is >> std::get(t); if constexpr (I + 1 < std::tuple_size_v) { return read_tuple(is, t); } return is; } template std::basic_ostream& write_tuple(std::basic_ostream& os, const Tuple& t) { os << std::get(t); if constexpr (I + 1 < std::tuple_size_v) { os << CharT(' '); return write_tuple(os, t); } return os; } }; template std::basic_istream& operator>>(std::basic_istream& is, std::pair& p) { is >> p.first >> p.second; return is; } template std::basic_istream& operator>>(std::basic_istream& is, std::tuple& p) { return tuple_io::read_tuple, 0>(is, p); } template std::basic_istream& operator>>(std::basic_istream& is, std::array& a) { for(auto& e : a) is >> e; return is; } template std::basic_istream& operator>>(std::basic_istream& is, std::vector& v) { for(auto& e : v) is >> e; return is; } template std::basic_ostream& operator<<(std::basic_ostream& os, const std::pair& p) { os << p.first << CharT(' ') << p.second; return os; } template std::basic_ostream& operator<<(std::basic_ostream& os, const std::tuple& p) { return tuple_io::write_tuple, 0>(os, p); } template std::basic_ostream& operator<<(std::basic_ostream& os, const std::array& a) { for(size_t i = 0; i < N; ++i) { if(i) os << CharT(' '); os << a[i]; } return os; } template std::basic_ostream& operator<<(std::basic_ostream& os, const std::vector& v) { for(size_t i = 0; i < v.size(); ++i) { if(i) os << CharT(' '); os << v[i]; } return os; } /** * @brief 空行出力 */ void print() { std::cout << '\n'; } /** * @brief 出力して改行 * * @tparam T 型 * @param x 出力する値 */ template void print(const T& x) { std::cout << x << '\n'; } /** * @brief 空白区切りで出力して改行 * * @tparam T 1つ目の要素の型 * @tparam Tail 2つ目以降の要素の型 * @param x 1つ目の要素 * @param tail 2つ目以降の要素 */ template void print(const T& x, const Tail&... tail) { std::cout << x << ' '; print(tail...); } #line 1 "/home/shogo314/cpp_include/sh-library/base.hpp" #include #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; using ull = unsigned long long; using str = string; using pl = pair; template using ml = map; using mll = map; using sl = set; using ld = long double; using pd = pair; template using vec = vector; template using vv = vector>; template using vvv = vector>>; template using vp = vector>; using vl = vec; using vvl = vv; using vvvl = vvv; using vs = vec; using vc = vec; using vi = vec; using vb = vec; using vpl = vec; using spl = set; using vd = vec; using vpd = vec; template using ary = array; template using al = array; template using aal = array, N1>; template using val = vec>; #define all(obj) (obj).begin(), (obj).end() #define reps(i, a, n) for (ll i = (a); i < ll(n); i++) #define rep(i, n) reps(i, 0, (n)) #define rrep(i, n) reps(i, 1, (n) + 1) #define repds(i, a, n) for (ll i = ((n) - 1); i >= (a); i--) #define repd(i, n) repds(i, 0, (n)) #define rrepd(i, n) repds(i, 1, (n) + 1) #define rep2(i, j, x, y) rep(i, x) rep(j, y) template inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } return false; } #define LL(x) ll x;cin >> x; #define VL(a,n) vl a(n);cin >> a; #define AL(a,k) al a;cin >> a; #define VC(a,n) vc a(n);cin >> a; #define VS(a,n) vs a(n);cin >> a; #define STR(s) str s;cin >> s; #define VPL(a,n) vpl a(n);cin >> a; #define VAL(a,n,k) val a(n);cin >> a; #define VVL(a,n,m) vvl a(n,vl(m));cin >> a; #define SL(a,n) sl a;{VL(b,n);a=sl(all(b));} template using heap_max = priority_queue, less>; template using heap_min = priority_queue, greater>; #line 3 "main.cpp" void solve() { LL(H); LL(W); VS(S, H); vvl X(H, vl(W)); { vv> tmp(H, val<4>(W, {-1, -1, -1, -1})); reps(i, 1, H) reps(j, 1, W) { if (S[i][j] == '.') continue; if (S[i - 1][j - 1] == '.') continue; tmp[i][j][0] = tmp[i - 1][j - 1][0] + 1; chmax(tmp[i][j][0], 1); } reps(i, 1, H) repd(j, W - 1) { if (S[i][j] == '.') continue; if (S[i - 1][j + 1] == '.') continue; tmp[i][j][1] = tmp[i - 1][j + 1][1] + 1; chmax(tmp[i][j][1], 1); } repd(i, H - 1) reps(j, 1, W) { if (S[i][j] == '.') continue; if (S[i + 1][j - 1] == '.') continue; tmp[i][j][2] = tmp[i + 1][j - 1][2] + 1; chmax(tmp[i][j][2], 1); } repd(i, H - 1) repd(j, W - 1) { if (S[i][j] == '.') continue; if (S[i + 1][j + 1] == '.') continue; tmp[i][j][3] = tmp[i + 1][j + 1][3] + 1; chmax(tmp[i][j][3], 1); } rep2(i, j, H, W) { X[i][j] = *min_element(all(tmp[i][j])); } } vvl ans(H, vl(W)); { vpl c; rep(i, H) { c.push_back({i, 0}); } rep(j, W) { c.push_back({0, j}); } ll t = -1; for (auto [i, j] : c) { while (true) { if (i < 0) break; if (i >= H) break; if (j < 0) break; if (j >= W) break; chmax(t, X[i][j]); if (t >= 0) { ans[i][j] = 1; } t--; i++; j++; } } } { vpl c; rep(i, H) { c.push_back({i, W - 1}); } rep(j, W) { c.push_back({0, j}); } ll t = -1; for (auto [i, j] : c) { while (true) { if (i < 0) break; if (i >= H) break; if (j < 0) break; if (j >= W) break; chmax(t, X[i][j]); if (t >= 0) { ans[i][j] = 1; } t--; i++; j--; } } } { vpl c; rep(i, H) { c.push_back({i, 0}); } rep(j, W) { c.push_back({H - 1, j}); } ll t = -1; for (auto [i, j] : c) { while (true) { if (i < 0) break; if (i >= H) break; if (j < 0) break; if (j >= W) break; chmax(t, X[i][j]); if (t >= 0) { ans[i][j] = 1; } t--; i--; j++; } } } { vpl c; rep(i, H) { c.push_back({i, W - 1}); } rep(j, W) { c.push_back({H - 1, j}); } ll t = -1; for (auto [i, j] : c) { while (true) { if (i < 0) break; if (i >= H) break; if (j < 0) break; if (j >= W) break; chmax(t, X[i][j]); if (t >= 0) { ans[i][j] = 1; } t--; i--; j--; } } } rep2(i, j, H, W) { if (S[i][j] == '#' and ans[i][j] == 0) { print("No"); return; } } print("Yes"); } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); solve(); }