#C14849. Minesweeper Board Simulation

    ID: 44543 Type: Default 1000ms 256MiB

Minesweeper Board Simulation

Minesweeper Board Simulation

This problem requires you to simulate a Minesweeper board. Given the board dimensions and the positions of bombs, you need to generate a board where each cell contains the number of bombs in its adjacent eight cells (if the cell is not a bomb) or -1 if the cell itself is a bomb.

For a cell at position \( (i,j) \), its neighboring cells include \( (i-1,j-1) \), \( (i-1,j) \), \( (i-1,j+1) \), \( (i,j-1) \), \( (i,j+1) \), \( (i+1,j-1) \), \( (i+1,j) \), and \( (i+1,j+1) \) (provided these indices are within board boundaries). If a cell is not a bomb, its value is given by \[ board[i][j] = \sum_{k=i-1}^{i+1} \sum_{l=j-1}^{j+1} I_{\{board[k][l] \; is \; a \; bomb\}} \] where \(I\) is the indicator function. Otherwise, if the cell is a bomb, output -1.

The board is represented as a 2D grid, and indices are 0-indexed.

inputFormat

The first line contains two integers \( r \) and \( c \) representing the number of rows and columns of the board.

The second line contains a single integer \( n \), the number of bombs on the board.

Each of the next \( n \) lines contains two space-separated integers that denote the 0-indexed row and column positions of a bomb.

outputFormat

Output the final board as \( r \) lines. Each line should contain \( c \) space-separated integers. For a bomb cell, print -1, and for a safe cell, print the count of bombs in all adjacent cells.

## sample
1 1
0
0

</p>