#P10419. [蓝桥杯 2023 国 A] 01 游戏
[蓝桥杯 2023 国 A] 01 游戏
Problem Description
Xiao Lan has recently been playing the game, a board game based on binary ideas. Specifically, the game is played on an board. Each cell on the board must contain a digit or . Initially, some cells already contain fixed digits, and the player is not allowed to change them. The player needs to fill in all other empty cells with digits so that the final board satisfies the following conditions:
- All empty cells must be filled with a digit .
- In the horizontal or vertical direction, the same digit cannot appear consecutively more than twice.
- In each row and each column, the number of 's and 's must be equal (for example, when , each row/column must contain zeros and ones).
- Every row must be unique, so no row can be exactly the same as another row. Similarly, every column must be unique, so no column can be exactly the same as another column.
Now please solve the game together with Xiao Lan! The problem guarantees that every testdata has a unique answer.
Input Format
The first line contains an integer , indicating the size of the board.
The next lines each contain characters. Each character is one of 0, 1, _ (ASCII codes are , , respectively). 0 means this cell is fixed as , 1 means this cell is fixed as , and _ means this is an empty cell to be filled by the player.
Output Format
Output lines, each containing characters, representing the solution. Each character can only be 0 or 1.
6
_0____
____01
__1__1
__1_0_
______
__1___
100110
010101
001011
101100
110010
011001
Hint
[Test Case Scale and Conventions]
For of the test cases, .
For all test cases, , and is even.
Thanks to @rui_er for providing the testdata.
Translated by ChatGPT 5