CF1335D.Anti-Sudoku
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a correct solution to a Sudoku puzzle. If you don't know what Sudoku is, you can read about it here.
The picture below shows a correct Sudoku solution:
Blocks are bordered in bold black.
Your task is to change at most 9 elements of this field (i. e., choose some 1≤i,j≤9 and change the number at the position (i,j) to any other number in the range [1;9]) to make it anti-sudoku. The anti-sudoku is the 9×9 field, in which:
- Any number in this field is in the range [1;9];
- Each row contains at least two equal elements;
- Each column contains at least two equal elements;
- Each 3×3 block (you can read what a block is following the link above) contains at least two equal elements.
It is guaranteed that a solution exists.
You have to answer t independent test cases.
你将得到一个正确的数独谜题解答。如果你不了解什么是数独,可以在此处查阅:链接。
下图展示了一个正确的数独解答:
其中各个宫(block)由粗黑线标出。
你的任务是至多修改该数独解答中的 9 个元素(即选择若干满足 1≤i,j≤9 的位置 (i,j),并将该位置上的数字替换为 [1,9] 范围内的任意其他数字),使其变为“反数独”(anti-sudoku)。所谓反数独,是指一个 9×9 的方阵,满足以下条件:
- 方阵中每个数字均属于区间 [1,9];
- 每一行至少包含两个相等的元素;
- 每一列至少包含两个相等的元素;
- 每一个 3×3 宫(关于“宫”的定义,请参见上方链接)至少包含两个相等的元素。
题目保证解一定存在。
你需要处理 t 个相互独立的测试用例。
输入格式
The first line of the input contains one integer t (1≤t≤104) — the number of test cases. Then t test cases follow.
Each test case consists of 9 lines; each line consists of 9 characters from 1 to 9 without any whitespaces — the correct solution of the Sudoku puzzle.
输入的第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。随后是 t 个测试用例。
每个测试用例由 9 行组成;每行包含 9 个字符,字符取自 1 到 9,中间无任何空白字符——即该数独题目的正确解。
输出格式
For each test case, print the answer — the initial field with at most 9 changed elements so that the obtained field is anti-sudoku. If there are several solutions, you can print any. It is guaranteed that the answer exists.
对于每个测试用例,输出答案——即一个至多修改了 9 个元素的初始数独盘面,使得所得盘面为反数独(anti-sudoku)。若存在多个解,输出任意一个即可。题目保证解一定存在。
输入输出样例
输入#1
1 154873296 386592714 729641835 863725149 975314628 412968357 631457982 598236471 247189563
输出#1
154873396 336592714 729645835 863725145 979314628 412958357 631457992 998236471 247789563
输入解题思路,AI测评打分。不知道怎么写?