PivotOJ

Simply Sudoku

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC ECNA 2020-2021BOJ 21159

문제

Sudoku puzzles come in all different shapes and difficulty levels. Traditionally a Sudoku puzzle is a 9×99\times9 grid. Initially, some of the cells are filled in with numbers and some are empty. The goal is to fill in each cell with a number in the range 11 -- 99 subject to the following restrictions:

  • Each digit 11 -- 99 must appear once in each row
  • Each digit 11 -- 99 must appear once in each column
  • Each digit 11 -- 99 must appear once in each 3×33\times3 sub-grid

The difficulty of a Sudoku puzzle can vary widely. The easiest puzzles can be solved with the following two simple techniques:

  • Single Value Rule: search for squares which only have one possible value that can be put there.
  • Unique Location Rule: within any row, column or sub-grid search for a value that can only be placed in one of the nine locations.

Consider the partially solved Sudoku puzzle shown in Figure 1.  The Single Value Rule applies to grid square A77 where 88 is the only value that can be placed there.  The Unique Location Rule can be used to put a 55 in square B33 as it is the only location in row 33 where a 55 can be placed.

Figure 1: Sample Input 11

The easiest Sudoku puzzles can be solved with only these two rules; harder puzzles use techniques like swordfish, x-wings and BUGs.

For this problem you will be given a Sudoku puzzle and must determine if it is an easy puzzle, i.e., whether it can be solved by just using the Single Value and Unique Location rules.

입력

Input consists of a single Sudoku puzzle given over nine lines.  Each line contains 99 values in the range 00 to 99, where a 00 indicates a blank in the puzzle.

출력

Output the word Easy followed by the solved Sudoku puzzle if it is an easy puzzle.  The puzzle should be printed on nine lines with a single space separating values on a line.  If the puzzle is not easy output Not easy followed by as much of the Sudoku puzzle as can be solved using the two rules described above.  Use the same format for the partial solution as for the complete solution using a '.' instead of a digit for a unfilled square.

예제

예제 1

입력
2 6 0 5 1 0 3 0 0
3 0 0 0 6 0 0 0 2
0 1 5 0 7 3 9 0 4
0 0 9 0 0 0 5 0 0
0 0 2 6 0 1 4 0 0
0 0 6 0 0 0 7 0 0
6 0 1 9 4 0 2 3 0
9 0 0 0 2 0 0 0 5
0 0 8 0 3 5 0 4 9
출력
Easy
2 6 4 5 1 9 3 7 8
3 9 7 8 6 4 1 5 2
8 1 5 2 7 3 9 6 4
1 3 9 4 8 7 5 2 6
5 7 2 6 9 1 4 8 3
4 8 6 3 5 2 7 9 1
6 5 1 9 4 8 2 3 7
9 4 3 7 2 6 8 1 5
7 2 8 1 3 5 6 4 9

예제 2

입력
0 0 0 0 0 0 7 0 1
0 0 0 0 0 1 2 3 5
0 0 1 8 0 0 0 0 6
0 0 0 0 2 5 0 9 3
9 0 0 0 0 0 0 0 2
3 1 0 6 7 0 0 0 0
2 0 0 0 0 3 8 0 0
1 3 8 9 0 0 0 0 0
4 0 6 0 0 0 0 0 0
출력
Not easy
. . 3 . . . 7 8 1
. . . . . 1 2 3 5
. . 1 8 3 . 9 4 6
. . . . 2 5 . 9 3
9 . . 3 . . . 7 2
3 1 2 6 7 9 4 5 8
2 . . . . 3 8 . .
1 3 8 9 . . 5 . .
4 . 6 . . . 3 . .
코드를 제출하려면 로그인하세요.