Minesweeper - MarisaOJ: Marisa Online Judge

Minesweeper

Time limit: 1000 ms
Memory limit: 256 MB
The Minesweeper game is played on an $n$-row by $m$-column grid. Each cell in the grid can either contain a mine or not. Players take turns selecting cells to reveal. If a cell does not contain a mine, the number of mines in the 8 neighboring cells is displayed. Players must use this information as hints to mark all cells containing mines. In this problem, instead of playing the game, you are given a grid $A$ consisting of $n$ rows and $m$ columns. The number in row $i$, column $j$ represents the number of mines in the 8 neighboring cells of cell $(i,j)$. Your task is to find cells containing mines. ### Input - The first line contains two integers $n$ and $m$. - The next $n$ lines each contain $m$ integers, representing the grid $A$. ### Output - Print a grid of $n$ rows and $m$ columns. The number in row $i$, column $j$ should be $1$ if cell $(i,j)$ contains a mine, otherwise $0$. ### Constraints - $1 \le n, m \le 20$. - $0 \le A_{i,j} \le 8$. ### Example Input: ``` 3 3 1 1 1 2 2 3 2 2 2 ``` Output: ``` 0 0 0 0 1 0 0 1 1 ```