using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); int h = inpt[0]; int w = inpt[1]; char[,] map = new char[h, w]; int[,] step = new int[h, w]; int maxHen = 0; for (int i = 0; i < inpt[0]; i++) { string row = Reader.ReadLine(); for (int j = 0; j < inpt[1]; j++) { map[i, j] = row[j]; if (row[j] == '#') { int val = 1; if (i == 0 || i == h - 1 || j == 0 || j == w - 1) { } else { val = Math.Min(step[i - 1, j - 1] + 1, Math.Min(step[i, j - 1] + 1, step[i - 1, j] + 1)); } step[i, j] = val; maxHen = Math.Max(maxHen, val); } } } Console.WriteLine((maxHen + 1) / 2); } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 8 8 .#..#... .######. #####... #####.#. ######## ######.# #####... ...####. "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }