#abc276h. Ex - Construct a Matrix
Ex - Construct a Matrix
Score : points
问题描述
确定是否存在一个 × 矩阵 满足以下条件,并在存在时给出一个这样的矩阵。 (令 表示位于从上到下的第 行和从左到右的第 列处的 的元素。)
- 对于所有 和 ,有 ,其中 。
- 对于每个 ,满足以下条件:
- 定义 $P = \prod_{a_i \leq j \leq b_i} \prod_{c_i \leq k \leq d_i} x_{j,k}$,则 除以 的余数等于 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Determine whether there is an -by- matrix that satisfies the following conditions, and present one such matrix if it exists. (Let denote the element of at the -th row from the top and -th column from the left.)
- for every and .
- The following holds for each .
- Let $P = \prod_{a_i \leq j \leq b_i} \prod_{c_i \leq k \leq d_i} x_{j,k}$. Then, is congruent to modulo .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
If no matrix satisfies the conditions, print No
.
If there is a matrix that satisfies them, print Yes
in the first line and one such instance of in the following format in the second and subsequent lines.
If multiple matrices satisfy the conditions, any of them will be accepted.
Sample Input 1
2 3
1 1 1 2 0
1 2 2 2 1
2 2 1 2 2
Sample Output 1
Yes
0 2
1 2
For example, for , we have $P = \prod_{a_2 \leq j \leq b_2} \prod_{c_2 \leq k \leq d_2} x_{j,k}= \prod_{1 \leq j \leq 2} \prod_{2 \leq k \leq 2} x_{j,k}=x_{1,2} \times x_{2,2}$.
In this sample output, we have and , so , which is congruent to modulo .
It can be similarly verified that the condition is also satisfied for and .
Sample Input 2
4 4
1 4 1 4 0
1 4 1 4 1
1 4 1 4 2
1 4 1 4 0
Sample Output 2
No
update @ 2024/3/10 11:38:46