ll@h,@w,a[h+1][w+1]{},c[][]{},d[w],n=0; rrep(y,h){ rrep(x,w){ char@s; if(s=='#'){ a[y][x]=min(a[y][x+1],a[y+1][x],a[y+1][x+1])+1; n+=1; } } } ll ok=1,ng=h+1; while(ok+1>1; ll m=n; rep(y,h){ ll e=0; rep(x,w){ if(a[y][x]>=k){ c[y][x]+=1; c[y][x+k]-=1; c[y+k][x]-=1; c[y+k][x+k]+=1; } e+=d[x]+=c[y][x]; c[y][x]=0; m-=e>0; } } (m?ng:ok)=k; } wt(ok);