#P4573. [CQOI2013] 新数独
[CQOI2013] 新数独
Description
Below is a Sudoku with no digits, only inequality relations (yes, those chevrons are all "greater-than" signs):

Besides the inequality relations (note that adjacent cells cannot be equal), it must also satisfy the usual Sudoku rules:
- Each cell is a digit from .
- Each row is a permutation of .
- Each column is a permutation of .
- Each subgrid (separated by bold lines in the figure above; there are such subgrids) is a permutation of .
As shown below, there is exactly one way to fill the Sudoku above:

For neatness, for each subgrid, the inequality relations for all pairs of adjacent cells will be given.
Input Format
There are lines in total, describing one instance of the new Sudoku. Lines contain left-right symbols (< and >), and the other lines contain up-down symbols (^ and v).
Output Format
Output lines, each containing digits from , separated by spaces. The input guarantees a unique solution.
> < < < > <
v ^ v v ^ v ^ ^ v
< < < > < <
v ^ v ^ v v ^ ^ v
< < < < > >
< > > > < >
v v ^ ^ v ^ ^ v v
< > > < > >
^ v v v ^ v v ^ v
> < < > > >
< > > > > <
v v v v ^ ^ ^ ^ ^
> < < < < <
^ ^ ^ ^ ^ v v v ^
> > < > < <
5 3 9 4 6 8 2 1 7
2 4 8 1 9 7 3 5 6
1 6 7 2 3 5 9 8 4
6 8 1 7 4 2 5 9 3
3 7 5 9 1 6 8 4 2
9 2 4 5 8 3 7 6 1
7 9 6 8 2 1 4 3 5
4 1 2 3 5 9 6 7 8
8 5 3 6 7 4 1 2 9
< > > < > <
v v ^ ^ v v ^ ^ ^
< < > < > <
^ ^ ^ v ^ ^ ^ v v
< < < < > >
> < > > > >
v ^ ^ ^ ^ v v v ^
> > > > < >
v v ^ v ^ v ^ v ^
> < < > > >
< < < < > <
v ^ v v v v ^ ^ v
< > > < < >
^ v v v ^ v ^ v v
< > < > < >
4 9 1 7 3 6 5 2 8
2 3 7 8 1 5 6 4 9
5 6 8 2 4 9 7 3 1
9 1 3 6 5 4 8 7 2
8 5 4 9 7 2 1 6 3
7 2 6 3 8 1 9 5 4
3 4 9 5 6 8 2 1 7
1 8 5 4 2 7 3 9 6
6 7 2 1 9 3 4 8 5
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号