eolymp
bolt
Try our new interface for solving problems
Problems

Sudoku

Sudoku

A Sudoku grid is a \textbf{16}×\textbf{16} grid of cells grouped in sixteen \textbf{4}×\textbf{4} squares, where some cells are filled with letters from \textbf{A} to \textbf{P} (the first \textbf{16} capital letters of the English alphabet), as shown in figure 1a. The game is to fill all the empty grid cells with letters from \textbf{A} to \textbf{P} such that each letter from the grid occurs once only in the line, the column, and the \textbf{4}×\textbf{4} square it occupies. The initial content of the grid satisfies the constraints mentioned above and guarantees a unique solution. \includegraphics{https://static.e-olymp.com/content/c7/c7aaaf83919c7db2d5c279fa02ac552f9b355495.jpg} \InputFile Each data set encodes a grid and contains \textbf{16} strings on \textbf{16} consecutive lines as shown in sample input/utput. The \textbf{i}^th string stands for the \textbf{i}^th line of the grid, is \textbf{16} characters long, and starts from the first position of the line. String characters are from the set \{\textbf{A}, \textbf{B}, …, \textbf{P}, \textbf{-}\}, where "\textbf{--}" (minus) designates empty grid cells. The data sets are separated by single empty lines and terminate with an end of file. \OutputFile The program prints the solution of the input encoded grids in the same format and order as used for input.
Time limit 1 second
Memory limit 64 MiB
Input example #1
--A----C-----O-I
-J--A-B-P-CGF-H-
--D--F-I-E----P-
-G-EL-H----M-J--
----E----C--G---
-I--K-GA-B---E-J
D-GP--J-F----A--
-E---C-B--DP--O-
E--F-M--D--L-K-A
-C--------O-I-L-
H-P-C--F-A--B---
---G-OD---J----H
K---J----H-A-P-L
--B--P--E--K--A-
-H--B--K--FI-C--
--F---C--D--H-N-
Output example #1
FPAHMJECNLBDKOGI
OJMIANBDPKCGFLHE
LNDKGFOIJEAHMBPC
BGCELKHPOFIMAJDN
MFHBELPOACKJGNID
CILNKDGAHBMOPEFJ
DOGPIHJMFNLECAKB
JEKAFCNBGIDPLHOM
EBOFPMIJDGHLNKCA
NCJDHBAEKMOFIGLP
HMPLCGKFIAENBDJO
AKIGNODLBPJCEFMH
KDEMJIFNCHGAOPBL
GLBCDPMHEONKJIAF
PHNOBALKMJFIDCEG
IAFJOECGLDPBHMNK