Universal Cup Judging System

Universal Cup

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓
統計

給定一個大小為 $n \times m$ 的二元矩陣 $A$。基本上,它就是一個有 $n$ 列與 $m$ 行的表格,其中每個格子的值為 $0$ 或 $1$。

在一次操作中,你可以選擇此矩陣中的一個格子 $(i, j)$,並翻轉該格子以及所有與其共享一條公共邊的格子中的值。形式化地說,對於每個滿足 $|s - i| + |t - j| \le 1$ 的格子 $(s, t)$($1 \le s \le n, 1 \le t \le m$),都會套用變換 $A_{s,t} \leftarrow 1 - A_{s,t}$。

請找出一種方式使矩陣中僅包含零元素,或者指出這是不可能的。

輸入格式

第一行包含兩個整數 $n$ 與 $m$($1 \le n, m \le 500$),代表矩陣的大小。

接下來 $n$ 行中的第 $i$ 行包含一個由 $m$ 個數位組成的二進位字串,對應矩陣的第 $i$ 列。

輸出格式

若無解,請在單獨一行中輸出單詞 NO。

否則,在第一行輸出單詞 YES。在接下來的 $n$ 行中,每行輸出一個長度為 $m$ 的二進位字串。這些字串構成一個維度為 $n \times m$ 的矩陣。當且僅當你打算對該格子進行操作時,其對應的元素才必須等於 $1$。

當然,所有選取的操作組合起來,必須能將初始矩陣轉換為全零矩陣。

若存在多種解,輸出其中任意一種即可。

你可以以任意大小寫輸出單詞。

範例

範例輸入 1

3 4
1000
0001
0100

範例輸出 1

YES
0100
0110
1100

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.