luogu#P10482. Sudoku 2

Sudoku 2

题目描述

In the game of Sudoku, you are given a large 9 × 9 grid divided into smaller 3 × 3 subgrids. For example,

Given some of the numbers in the grid, your goal is to determine the remaining numbers such that the numbers 1 through 9 appear exactly once in (1) each of nine 3 × 3 subgrids, (2) each of the nine rows, and (3) each of the nine columns.

输入格式

The input test file will contain multiple cases. Each test case consists of a single line containing 81 characters, which represent the 81 squares of the Sudoku grid, given one row at a time. Each character is either a digit (from 1 to 9) or a period (used to indicate an unfilled square). You may assume that each puzzle in the input will have exactly one solution. The end-of-file is denoted by a single line containing the word “end”.

输出格式

For each test case, print a line representing the completed Sudoku puzzle.

题目大意

【题目描述】

在数独游戏中,给定一个大的 9 × 9 网格,分成了较小的 3 × 3 子网格。例如,

在给定网格中的一些数字后,你的目标是确定剩余的数字,使得数字 1 到 9 恰好出现在以下位置:(1) 九个 3 × 3 子网格中的每一个,(2) 九行中的每一个,以及 (3) 九列中的每一个。

【输入格式】

输入测试文件将包含多个案例。每个测试案例由一行组成,其中包含 81 个字符,这些字符代表数独网格的 81 个方格,逐行给出。每个字符可以是一个数字(从 1 到 9)或一个句点(用于表示未填充的方格)。你可以假设输入中的每个谜题都有唯一解。文件的结尾由一行包含单词“end”表示。

【输出格式】

对于每个测试案例,打印一行表示完成的数独谜题。

翻译来自于:ChatGPT

.2738..1..1...6735.......293.5692.8...........6.1745.364.......9518...7..8..6534.
......52..8.4......3...9...5.1...6..2..7........3.....6...1..........7.4.......3.
end
527389416819426735436751829375692184194538267268174593643217958951843672782965341
416837529982465371735129468571298643293746185864351297647913852359682714128574936