QOJ.ac

QOJ

実行時間制限: 5 s メモリ制限: 256 MB 満点: 100

#5640. 紧凑数独

統計

几乎每个计算机科学专业的学生都曾编写过标准的数独求解程序。为了增加挑战性,我们在标准数独的基础上做了一些小改动。

数字 $1$ 到 $9$ 被填入一个 $6 \times 6$ 的网格中,使得每一行、每一列或如下图所示的每个 $3 \times 2$ 的区域内没有重复的数字。网格中的某些方格被斜线分割,需要填入两个数字。较小的数字总是位于斜线上方。

不完整的网格与已完成的网格

对于本题,你需要编写一个程序,输入一个不完整的数独网格,并输出该数独的解。

输入格式

输入的第一行包含一个十进制整数 $P$ ($1 \le P \le 100$),表示随后数据组的数量。每组数据应被独立且相同地处理。

每组数据包含 $7$ 行输入。第一行包含数据组编号 $K$。接下来的 $6$ 行表示一个不完整的 Tight-Fit 数独网格,每行有 $6$ 个数据元素,以空格分隔。数据元素可以是一个数字 ($1-9$)、一个表示空白格的短横线 ('-'),或者两个由斜线 ('/') 分隔的元素。

输出格式

对于每组数据,输出 $7$ 行。第一行输出数据组编号 $K$。接下来的 $6$ 行显示对应输入数据组的解。每行包含 $6$ 个数据元素,以空格分隔。数据元素可以是一个数字 ($1-9$),或者两个由斜线 ('/') 分隔的数字。

样例

样例输入 1

1
1
-/- -/5 4 3 2 -/-
- 6 -/- -/- - -/-
- 7/- - -/- -/- 2
8 -/- -/- - -/3 -
-/- - -/- -/- 4 -
-/- 8 7 6 5/- -/-

样例输出 1

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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.