Editorial for COCI '23 Contest 1 #1 Sudoku
Submitting an official solution before solving the problem yourself is a bannable offence.
Prepared by: Martina Licul
The input data for this problem is not very convenient for solving, but we can reshape it into a more manageable format. A useful representation for solving this problem is to express the Sudoku grid as a matrix of size , with cells to be filled with numbers.
Now, to determine if there is a mistake in the given Sudoku grid, we need to apply the three rules of Sudoku:
Check rows: For each row in the grid, count the number of occurrences of each digit from to . If any digit occurs more than once, there is a mistake.
Check columns: Similarly, for each column in the grid, count the number of occurrences of each digit from to . If any digit occurs more than once, there is a mistake.
Check subgrids: Divide the grid into nine subgrids. For each subgrid, repeat the process from steps 1 and 2, but instead of rows and columns, check the subgrid.
If none of the checks in steps 1, 2, and 3 found a mistake, that means the board is valid.
Comments