#P9903. Sudoku Error Checker

    ID: 23048 Type: Default 1000ms 256MiB

Sudoku Error Checker

Sudoku Error Checker

A Sudoku is a popular logic puzzle in which the player must fill a \(9\times9\) grid with digits such that each digit from \(1\) to \(9\) appears exactly once in each row, each column, and each of the \(3\times3\) sub-boxes. In this problem, you are given a partially filled Sudoku grid and are required to determine whether an error exists in the current state.

An error is defined as the existence of any row, column, or \(3\times3\) sub-box that contains any digit (\(1\) through \(9\)) two or more times.

For example, the grid shown below does not contain an error:

Sudoku grid

inputFormat

The input consists of 9 lines. Each line contains 9 characters separated by spaces. Each character is either a digit from \(1\) to \(9\) (representing a filled cell) or a dot '.' (representing an empty cell).

outputFormat

Output a single line containing true if there is an error in the grid, or false if the grid is error-free.

sample

5 3 . . 7 . . . .
6 . . 1 9 5 . . .
. 9 8 . . . . 6 .
8 . . . 6 . . . 3
4 . . 8 . 3 . . 1
7 . . . 2 . . . 6
. 6 . . . . 2 8 .
. . . 4 1 9 . . 5
. . . . 8 . . 7 9
false