#P6410. [COCI 2008/2009 #3] CROSS

[COCI 2008/2009 #3] CROSS

Description

In this problem, you need to use the simplest method, namely cross-hatching.

In the grid, we choose one digit among the 99 digits, and for every occurrence of this digit in the grid, we cross out the corresponding row, column, and 3×33 \times 3 box. Find a 3×33 \times 3 box where the position of this digit can be determined, and place it there.

The system will give you a partially filled grid. Your task is to repeatedly use the cross-hatching method for different digits, until no further deduction can be made for any digit.

The first picture below shows a very sparse Sudoku. However, even though it is so sparse, in this grid you can still use cross-hatching to deduce that the digit in the top-left cell is 44, as shown in the second picture.

In addition, you need to output ERROR\tt ERROR in the following cases:

  • The initial placement of digits in the grid is invalid.
  • For some digit, it cannot be placed in any of the 3×33 \times 3 boxes.

Input Format

The input consists of 99 lines, each containing 99 characters. Each character is either a digit from 11 to 99, or .\tt . indicating an empty cell.

Output Format

If the input is valid and there is no contradiction during solving, output the grid in the same format as the input.

Fill in the cells whose values can be deduced using cross-hatching.

Otherwise, output ERROR\tt ERROR.

..9......
.....4...
.......4.
.........
.4.......
.........
.........
.........
......... 

4.9......
.....4...
.......4.
.........
.4.......
.........
.........
.........
......... 

...1...6.
18...9...
..7.642..
2.9..6.5.
.43...72.
.6.3..9.1
..265.1..
...2...97
.5...3... 
524137869
186529473
397864215
219476358
843915726
765382941
972658134
638241597
451793682 
1........
..1......
.......1.
.........
.........
.........
.........
.........
......... 

ERROR 

........2
....1....
1........
......1..
.........
.........
.........
.......1.
......... 

ERROR 

Hint

Note

This problem is translated from COCI2008-2009 CONTEST #3 T3 CROSS.

Translated by ChatGPT 5