eolymp
bolt
Try our new interface for solving problems
Problems

Sudoku

Sudoku

In the game of Sudoku, you are given a large \textbf{9}×\textbf{9} grid divided into smaller \textbf{3}×\textbf{3} subgrids. For example, \includegraphics{https://static.e-olymp.com/content/b3/b331223804dfbb4a04a0e2c738137219f3ba060b.jpg} Given some of the numbers in the grid, your goal is to determine the remaining numbers such that the numbers \textbf{1} through \textbf{9} appear exactly once in \begin{itemize} \item (\textbf{1}) each of nine \textbf{3}×\textbf{3} subgrids, \item (\textbf{2}) each of the nine rows, and \item (\textbf{3}) each of the nine columns. \end{itemize} \InputFile The input test file will contain multiple cases. Each test case consists of a single line containing \textbf{81} characters, which represent the \textbf{81} squares of the Sudoku grid, given one row at a time. Each character is either a digit (from \textbf{1} to \textbf{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 "\textbf{end}". \OutputFile For each test case, print a line representing the completed Sudoku puzzle.
Time limit 1 second
Memory limit 64 MiB
Input example #1
.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
Output example #1
527389416819426735436751829375692184194538267268174593643217958951843672782965341
416837529982465371735129468571298643293746185864351297647913852359682714128574936