QOJ.ac

QOJ

时间限制: 1 s 内存限制: 256 MB 总分: 100

#3527. 瓦尔瓦拉与矩阵

统计

有人送给 Varvara 一个 $n \times m$ 的矩阵,其中包含 $0$ 到 $k$ 之间的数字。该矩阵的每一行和每一列最多包含一个 $0$。

定义矩阵的“美观度”为四个角数字相等的不同矩形的数量。形式上,矩阵的美观度是满足 $1 \le x_1 < x_2 \le n$,$1 \le y_1 < y_2 \le m$ 且 $a_{x_1,y_1} = a_{x_1,y_2} = a_{x_2,y_1} = a_{x_2,y_2}$ 的不同集合 $\{x_1, x_2, y_1, y_2\}$ 的数量。

Varvara 对以下问题很感兴趣:她能否将矩阵中的每个 $0$ 替换为整数 $A$ 或 $B$,使得矩阵的美观度保持不变?注意,每个 $0$ 都是独立替换的。

输入格式

第一行包含两个整数 $n$ 和 $m$,分别表示矩阵的行数和列数。第二行包含一个整数 $k$。第三行包含两个整数 $A$ 和 $B$,表示可以用来替换矩阵中 $0$ 的数字。接下来的 $n$ 行,每行包含 $m$ 个空格分隔的整数 $a_{i,j}$,表示给定的矩阵。

数据范围

$2 \le n, m \le 10^3$ $2 \le k \le n \cdot m$ $1 \le A, B \le k, A \neq B$ $0 \le a_{i,j} \le k$

输出格式

如果可以在保持矩阵美观度不变的情况下替换所有 $0$,则输出“Yes”并打印替换后的 $n$ 行矩阵。否则,输出一行“No”。

样例

样例输入 1

4 4
5
3 5
1 1 0 3
0 5 4 5
1 1 4 4
2 5 3 0

样例输出 1

Yes
1 1 5 3
5 5 4 5
1 1 4 4
2 5 3 3

样例输入 2

4 4
4
1 2
1 1 3 3
1 0 2 3
1 2 0 3
1 3 1 3

样例输出 2

No

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.