#ifdef t9unkubj #include"debug.cpp" //#include"template_no_debug.h" #else #define dbg(...) 199958 #endif #undef _GLIBCXX_DEBUG #pragma GCC optimize("O3") using namespace std; #include using ll=long long; using ull=unsigned long long; templateusing vc=vector; templateusing vvc=vc>; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define REP(i,j,n) for(ll i=(j);i<(ll)(n);i++) #define DREP(i,n,m) for(ll i=(n);i>=(m);i--) #define drep(i,n) for(ll i=((n)-1);i>=0;i--) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() template bool chmin(T &x, F y){ if(x>y){ x=y; return true; } return false; } template bool chmax(T &x, F y){ if(x #include template struct sparse_table{ std::vector>data; std::vectortable; using F=std::function; F op; vectora; int n; sparse_table()=default; sparse_table(int n,F op):n(n),a(n),op(op){} sparse_table(int n,std::vectora,F op):n(n),op(op),a(a){ build(); } void set(int i,T x){ a[i]=x; } void build(){ int log{1}; while((1<>(log,std::vector(n)); data[0]=a; for(int i=1;i>h>>w; vcs(h); rep(i,h)cin>>s[i]; auto op=[&](int a,int b){ return min(a,b); }; sparse_table dp(w,op); rep(j,w){ if(s[h-1][j]=='.'&&s[h-2][j]=='.'){ dp.set(j,0); }else dp.set(j,1e9); } drep(i,h-1){ dp.build(); sparse_tablendp(w,op); rep(j,w){ if(s[i][j]=='.'){ int ac=w,wa=-1; while(ac-wa>1){ int wj=ac+wa>>1; int l=max(0ll,j-wj); int r=min(w,j+wj+1); if(dp.prod(l,r)<=wj){ ac=wj; }else wa=wj; } ndp.set(j,ac); }else ndp.set(j,1e9); } dp=move(ndp); if(i){ rep(j,w)if(s[i-1][j]=='#')dp.set(j,1e9); } } rep(i,w){ cout<sync_with_stdio(0); pass_time=clock(); int t=1; //cin>>t; while(t--)solve(); pass_time=clock()-pass_time; dbg(pass_time/CLOCKS_PER_SEC); }