#include #include using namespace std; using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair; using lb = long double; using T = tuple; #ifdef LOCAL # include # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast(0)) #endif int op(int a, int b) { return min(a,b); } int e(){ return 1e9; } int main() { int h, w; cin >> h >> w; vector s(h); rep(i,h) cin >> s[i]; vector> d(h, vector(w)); rep(j,w) d[h-1][j] = 0; for(int i=h-2;i>=0;i--){ vector l(w, -1), r(w, w); rep(j,w) { if(s[i][j]=='#') { l[j] = j; } if(j-1>=0) l[j] = max(l[j], l[j-1]); } for(int j=w-1;j>=0;j--){ if(s[i][j]=='#') { r[j] = j; } if(j+1 seg(d[i+1]); rep(j,w){ if(s[i][j]=='#') d[i][j] = 1e9; else{ int high = w; int low = -1; while(high-low>1){ int mid = (high+low)/2; int val = seg.prod(max(max(0, l[j]+1), j-mid), min(min(w, r[j]), j+mid+1)); if(val<=mid) high = mid; else low = mid; } d[i][j] = high; } } } dbg(d); rep(j,w){ cout << d[0][j] << "\n"; } return 0; }