#P9490. ZHY 的矩阵
ZHY 的矩阵
Problem Description
In ZHY's memory, there is a - matrix with rows and columns, which satisfies the following conditions:
- Each column contains at most one .
- For any two adjacent 's in the same row, within the rectangle of rows between the two columns (including these two columns), there are at least three 's in total.
Suddenly, ZHY recalled the values of positions in the matrix. Please calculate how many ways there are to fill the remaining positions of so that satisfies the conditions.
Formally, let the value in row and column be . Then satisfies:
-
For all , .
-
For all , .
-
For all and , if $A_{p,i}=A_{p,j}=1,\displaystyle \sum_{x=i}^{j}A_{p,x}=2$, then $\Big(\displaystyle \sum_{x=1}^{k} \sum_{y=i}^{j} A_{x,y}\Big) \ge 3$.
-
For all , .
Since the answer may be very large, you only need to output the result modulo . Define that two matrices are different if and only if there exist , such that .
Input Format
The first line contains three integers .
The next lines each contain three integers .
Output Format
Output one integer in a single line, representing the answer.
3 2 2
1 1 1
2 2 0
2
Hint
Sample Explanation
There are only the following matrices that satisfy the conditions:
This problem uses bundled testdata.
| Special Properties | Score | |||
|---|---|---|---|---|
| None | ||||
| None | ||||
Constraints: for all testdata, , , . , , . It is guaranteed that there do not exist such that .
Translated by ChatGPT 5