#P9237. [蓝桥杯 2023 省 A] 像素放置
[蓝桥杯 2023 省 A] 像素放置
Problem Description
Xiao Lan has recently become addicted to a game called "Pixel Placement". The game is played on an grid board. The board has rows, and each row contains cells. The player's task is to fill the cells with pixels, using only two colors: black or white.
Some cells contain an integer digit . This means that among the cells consisting of this cell plus the eight adjacent cells in the surrounding directions (up, down, left, right, upper-left, upper-right, lower-left, lower-right), there are exactly cells that must be filled with black.
The player needs to fill the grid while satisfying all numeric constraints. Please help Xiao Lan complete it. The problem guarantees that a solution exists for all testdata and that the solution is unique.
Input Format
The first line contains two integers , separated by a space, representing the board size.
The next lines each contain characters, describing the board layout. A character may be a digit , meaning a number on the grid. It may also be an underscore ( code ), meaning a normal cell without a number.
Output Format
Output lines, each containing characters, representing the answer. If a cell is filled with white, output the character 0. If a cell is filled with black, output the character 1.
6 8
_1__5_1_
1_4__42_
3__6__5_
___56___
_688___4
_____6__
00011000
00111100
01000010
11111111
01011110
01111110
Hint
Sample Explanation

In the figure above, the left side is the board layout corresponding to the sample input, and the right side is the solution to that game. For example, the cell at row , column contains the number . Around it, there are exactly cells filled with black: the cells at row , column , row , column , and row , column .
Constraints
For of the test cases, .
For all test cases, .
Translated by ChatGPT 5