#ABC472D. 疯狂炸弹 / Bomber Mad
疯狂炸弹 / Bomber Mad
Problem Statement
There is a grid with rows and columns. Each cell is an empty cell or a bomb cell. Let denote the cell at the -th row from the top and the -th column from the left. The grid is given by length- strings : if the -th character of is ., is an empty cell, and if the -th character of is #, is a bomb cell.
For an empty cell , if there is no bomb cell in the -th row nor in the -th column, that cell is called a safe empty cell.
In one move, you can move from the current cell to an adjacent empty cell in the up, down, left, or right direction (you cannot move to a bomb cell). Find the number of empty cells satisfying the following condition:
- A safe empty cell can be reached from in at most moves.
Constraints
- is a string of length consisting of
.and#. - , , and are integers.
Input
The input is given from Standard Input in the following format:
Output
Output the number of empty cells satisfying the condition.
3 3 1
#..
...
..#
5
The only safe empty cell is . There are five empty cells from which you can reach in at most one move: , so the answer is .
2 3 0
...
...
6
Since there is no bomb cell, all six cells are safe empty cells. Therefore, every empty cell satisfies the condition with zero moves.
5 7 2
..#....
..#....
.......
...#...
...#...
29
- Source: AtCoder ABC 472 D
相关
在下列比赛中: