Minesweeper
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F1686c7e4-9501-4675-90b4-23eeef7f527c%2FMinesweeper-750x464.jpg?table=block&id=34bb7016-c9c7-4d9e-a115-870f1da02cb3&cache=v2)
In the game Minesweeper, every cell can either be a number or a bomb. If it’s a number, it shows how many bombs are around that cell (the neighboring 8 cells - the top, bottom, left, right, and all the diagonally adjacent cells).
Given an
field, it’s required to place b
bombs on the field, and print the final field in the output. All the coordinates with a bomb should have a b
instead of a number.The first line of the input contains 2 numbers the height
h
and width w
of the field (1 ≤ h, w ≤ 50). The second line contains the number of bombs b
. Each of the next b
lines contains the coordinates of the bombs
(row and column, where the numbering starts from 1).The program should output the final grid, where each cell is either a bomb annotated with a
b
, or one of the numbers which represent the number of adjacent bombs to that cell.Input | Output |
3 2
2
1 1
2 2 | b 2
2 b
1 1 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB