atcoder#AGC033A. [AGC033A] Darker and Darker
[AGC033A] Darker and Darker
Score : points
Problem Statement
You are given a grid of squares with horizontal rows and vertical columns, where each square is painted white or black.
characters from to represent the colors of the squares.
is #
if the square at the -th row from the top and the -th column from the left is black, and is .
if that square is white.
We will repeatedly perform the following operation until all the squares are black:
- Every white square that shares a side with a black square, becomes black.
Find the number of operations that will be performed. The initial grid has at least one black square.
Constraints
- is
#
or.
. - The given grid has at least one black square.
Input
Input is given from Standard Input in the following format:
Output
Print the number of operations that will be performed.
3 3
...
.#.
...
2
After one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.
6 6
..#..#
......
#..#..
......
.#....
....#.
3