#P16025. [ICPC 2021 NAC] You be The Judge, Again
[ICPC 2021 NAC] You be The Judge, Again
题目描述
You are a judge, again! The contest you’re judging includes the following problem:
“You have one L-shaped triomino of each of different colors. Tile a by grid using each of these triominos such that there is exactly one blank square and all other squares are covered by exactly one square of such a triomino. All triominos must be used.”
Your team is to write a checker for this problem. Validation of the input values and format has already taken place. You will be given a purported tiling of a by grid, where each square in the grid is either or a positive integer from to representing one of the colors. Determine if it is, indeed, a covering of the grid with unique triominos and a single empty space.
L-shaped triominos look like this:
:::align{center}
:::
输入格式
The first line of input contains a single integer (), which is the of the description.
Each of the next lines contains integers (), where represents an empty space, and any positive number is a unique identifier of a triomino.
输出格式
Output a single integer, which is if the given grid is covered with unique triominos and a single empty space. Otherwise, output .
2
1 1 2 2
1 3 3 2
4 4 3 5
4 0 5 5
1
1
1 1
1 1
0