#K39507. Unique Photo ID Arrangement
Unique Photo ID Arrangement
Unique Photo ID Arrangement
In this problem, you are given an n × n grid representing photo IDs. Some cells are prefilled with values from 1 to n while empty cells are denoted by 0. Your task is to determine whether it is possible to fill all the empty cells such that every row and every column contains all distinct photo IDs. Formally, you need to check if the grid can be completed under the constraint that each row and column forms a unique sequence of numbers from 1 to n. All formulas in this problem (if any) are presented in LaTeX format.
inputFormat
The input is read from standard input. The first line contains an integer (n) (the size of the grid). The following (n) lines each contain (n) space-separated integers representing the grid. A 0 indicates an empty cell that needs to be filled with an integer from 1 to (n).
outputFormat
Output to standard output a single line: (True) if it is possible to fill the grid while ensuring that every row and column has unique numbers, otherwise (False).## sample
3
1 2 0
0 3 1
2 1 3
False