#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int H,W; cin >> H >> W; vector S(H); for(auto &s : S) cin >> s; vector UL(H,vector(W)),UR = UL,DL = UL,DR = UL; for(int i=0; i0; i--) for(int k=0; k> R(H,vector(W)); for(int i=0; i> ok(H,vector(W)); for(int i=0; i= 0 && k-1 >= 0) continue; int x = i,y = k,r = -1; stack> st; while(x < H && y < W){ if(S.at(x).at(y) == '.'){x++,y++; continue;} if(R.at(x).at(y) != 0) r = max(r,R.at(x).at(y)); if(r == -1) st.push({x,y}); else{ ok.at(x).at(y) = true; while(st.size()){ auto [bx,by] = st.top(); if(x-bx <= r) ok.at(bx).at(by) = true,st.pop(); else break; } r--; } x++; y++; } } for(int i=0; i= 0 && k+1 < W) continue; int x = i,y = k,r = -1; stack> st; while(x < H && y >= 0){ if(S.at(x).at(y) == '.'){x++,y--; continue;} if(R.at(x).at(y) != 0) r = max(r,R.at(x).at(y)); if(r == -1) st.push({x,y}); else{ ok.at(x).at(y) = true; while(st.size()){ auto [bx,by] = st.top(); if(x-bx <= r) ok.at(bx).at(by) = true,st.pop(); else break; } r--; } x++; y--; } } bool yes = true; for(int i=0; i