SUDOGOB - Sudoku goblin

题意翻译

# 题目大意 给定一个 $9 * 9$ 的数独,输出可填的方案数。 如果有唯一解,输出唯一解的方案。 # 输入输出格式 ## 输入格式 给定一个 $T$,接下来有 $T$ 组数据,每组9列,为一个 $9 * 9$ 的数独。每组数据由一个空行隔开。 ## 输出格式 一共 $T$ 组答案,每组第一行是方案数,如果是唯一解下方9列输出方案。每组答案没有空行间隔。

题目描述

A sudoku goblin has read your book with sudoku problems. He has erased or added some numbers from settings. Your task is to write a program that can detect modified settings. For every sudoku setting you have to count number of possible solutions and in the case that it is equal to 1 print the unique solution.

输入输出格式

输入格式


There is a number T of the test cases on the first line folowed by T sudoku tables separated by one empty line. One sudoku table consists of 9 lines of 9 numbers 0-9 separated by one space. Zero in the table marks the empty field.

输出格式


For every test case, one line with number of possible solutions optionally followed by solved sudoku in the same format as on the input.

输入输出样例

输入样例 #1

3
3 0 6 0 0 2 5 0 0
0 0 0 0 3 8 0 0 0
7 0 8 0 1 6 0 9 0
0 0 7 0 0 3 8 6 0
8 2 0 0 7 0 0 4 5
0 6 3 1 0 0 9 0 0
0 7 0 3 5 0 6 0 2
0 0 0 8 2 0 0 0 0
0 0 2 9 0 0 7 0 4

3 0 6 0 0 2 5 0 3
0 0 0 0 3 8 0 0 0
7 0 8 0 1 6 0 9 0
0 0 7 0 0 3 8 6 0
8 2 0 0 7 0 0 4 5
0 6 3 1 0 0 9 0 0
0 7 0 3 5 0 6 0 2
0 0 0 8 2 0 0 0 0
0 0 2 9 0 0 7 0 4

3 0 6 0 0 2 0 0 0
0 0 0 0 3 8 0 0 0
7 0 8 0 1 6 0 9 0
0 0 7 0 0 3 8 6 0
8 2 0 0 7 0 0 4 5
0 6 3 1 0 0 9 0 0
0 7 0 3 5 0 6 0 2
0 0 0 8 2 0 0 0 0
0 0 2 9 0 0 7 0 4

输出样例 #1

1
3 1 6 4 9 2 5 7 8 
2 9 5 7 3 8 4 1 6 
7 4 8 5 1 6 2 9 3 
9 5 7 2 4 3 8 6 1 
8 2 1 6 7 9 3 4 5 
4 6 3 1 8 5 9 2 7 
1 7 9 3 5 4 6 8 2 
6 3 4 8 2 7 1 5 9 
5 8 2 9 6 1 7 3 4 
0
2