report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Minesweeper - FlandreOJ: Flandre 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 ```
Backtracking
Binary string
ABC string
Subset sum
Subset
Permutations
Group division
Knight's tour
N-queens problem
Maximum path
Knapsack
Build array
Sudoku
Minesweeper
Travelling Salesman Problem
Word search
Topic
Basic
Rating 800
Solution (1) Solution