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]; int[,] step = new int[H, W]; char[,] map = new char[H, W]; Queue q = new Queue(); for(int i=0; i 0) { int[] task = q.Dequeue(); int posY = task[0]; int posX = task[1]; int cnt = task[2]; if((step[posY, posX] == 0 && map[posY, posX] == '#') || (cnt == 0 && map[posY , posX] == '.')) { step[posY, posX] = cnt; for(int i = Math.Max(0, posY-1); i<= Math.Min(H-1, posY+1); i++) { for(int j=Math.Max(0, posX - 1); j<= Math.Min(W-1, posX+1); j++) { if(i==posY && j == posX) { continue; } if(map[i,j] == '#' ) { int[] newT = new int[]{i,j, cnt+1}; q.Enqueue(newT); } } } } } int ans = 0; for(int i=0; i