Marko is a regular university student who still shows up to every lecture, even
though his stomach and head often ache from studying late into the night. Because
he’s also a gifted student, he often finds the lectures boring, so instead of listening
he plays his favorite game, Minesweeper. Eventually, even that got boring, so he
decided to create his own version of the game.
In Marko’s version of Minesweeper, he starts the game already knowing the positions
of all \(k\) bombs on a board with \(n\) rows and \(m\) columns. Each cell can contain at
most one bomb.
His task is to fill every non-bomb cell with the number of bombs in the eight
surrounding cells. Cells that contain bombs are marked with "B". Your task is to output the matrix
generated according to Marko’s rules.
In the first line are the natural numbers \(n\), \(m\) and \(k\) (\(1 \le n\), \(m \le 500\), \(1 \le k \le n \cdot m\)), the numbers from
the problem statement.
In each of the following \(k\) lines are the numbers \(r_{i}\) and \(s_{i}\) (\(1 \le r_{i} \le n\), \(1 \le s_{i} \le m\)), the row and column
in which one of the bombs is located.
Izlazni podaci
In \(n\) rows, output \(m\) characters separated by a space, the matrix produced according to the rules of
Marko’s game.
Scoring
Subtask
Points
Constraints
1
15
\(n = 1\)
2
18
\(k = 1\)
3
17
No additional constraints.
| 서브태스크 | 점수 | 설명 |
|---|---|---|
1 | 15점 | \(n = 1\) |
2 | 18점 | \(k = 1\) |
3 | 17점 | No additional constraints. |
1 6 1
1 30 1 B 1 0 03 3 3
1 1
2 3
1 3B 3 B
1 3 B
0 1 1Clarification of the first example: In the cell in the 3rd column there is a bomb (the letter "B"). The
cells of the matrix in the 2nd and 4th columns (marked with the number 1) are adjacent to it.