#P9237. Pixel Placement Puzzle
Pixel Placement Puzzle
Pixel Placement Puzzle
In this problem, you are given an grid. Some cells contain a digit () which indicates that in the block centered at that cell (including the cell itself), there must be exactly black cells. The other cells do not contain any constraints. Your task is to fill the entire grid with either black ('B') or white ('W') colors such that all given constraints are satisfied. It is guaranteed that there is a unique solution.
inputFormat
The first line contains two integers and , representing the number of rows and columns of the grid. The following lines each contain tokens separated by spaces. Each token is either a digit ('0'-'9') indicating a constraint, or a dot ('.') indicating that there is no constraint in that cell.
outputFormat
Output lines, each containing characters. Each character must be either 'B' (for a black cell) or 'W' (for a white cell). This output grid should satisfy all the constraints given in the input.
sample
4 4
2 . 2 .
. 5 . .
. . 4 .
. . . 2
BWBW
WBWW
WBBW
WWWB
</p>