#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int MAX_H = 3000; const int MAX_W = 3000; int max_dist[MAX_H + 2][MAX_W + 2]; struct Node { int by; int bx; int y; int x; int dist; Node(int by = -1, int bx = -1, int y = -1, int x = -1, int dist = -1) { this->by = by; this->bx = bx; this->y = y; this->x = x; this->dist = dist; } bool operator>(const Node &n) const { return dist > n.dist; } }; int main() { int H, W; cin >> H >> W; priority_queue , greater> pque; memset(max_dist, -1, sizeof(max_dist)); vector S; for (int y = 1; y <= H; ++y) { string row; cin >> row; S.push_back(row); for (int x = 1; x <= W; ++x) { if (row[x - 1] == '.') { max_dist[y][x] = 0; } } } for (int y = 0; y < H + 2; ++y) { for (int x = 0; x < W + 2; ++x) { if (y == 0 || x == 0 || y == H + 1 || x == W + 1) { max_dist[y][x] = 0; } } } int ans = 1; for (int y = 1; y <= H; ++y) { for (int x = 1; x <= W; ++x) { if (S[y - 1][x - 1] == '.') continue; int d1 = max(0, max_dist[y - 1][x - 1]); int d2 = max(0, max_dist[y - 1][x]); int d3 = max(0, max_dist[y][x - 1]); max_dist[y][x] = min(d1, min(d2, d3)) + 1; ans = max(ans, max_dist[y][x]); } } cout << (ans + 1) / 2 << endl; return 0; }