#P4961. 小埋与扫雷
小埋与扫雷
Description
Umaru will tell you a Minesweeper board, represented by an matrix, where means a mine and means not a mine. Please tell her the of this board.
A cell that is not a mine and has no mines in the eight surrounding cells is called an "empty cell". A cell that is not a mine and has at least one mine in the eight surrounding cells is called a "number cell". An 8-connected component consisting of "empty cells" is called an "empty area". (the number of "number cells" that have no "empty cells" in their eight surrounding cells) (the number of "empty areas").
If you cannot understand the computation above, you can read the tutorial given in the Background, or see the sample explanation below.
Note: 8-connectivity
Input Format
The first line contains two integers and , meaning the Minesweeper board is an matrix.
The next lines each contain integers, describing the matrix. Each number is either or . means the cell is a mine, and means it is not a mine.
Output Format
Output one integer, representing the of this Minesweeper board.
8 8
0 0 0 1 1 0 0 0
1 0 0 1 0 0 0 1
1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
13
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号