Universal Cup Judging System

Universal Cup

Limite de temps : 1.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

נתונה מטריצה בינארית $A$ בגודל $n \times m$. בעיקרון, זוהי פשוט טבלה של $n$ שורות ו-$m$ עמודות, שלכל תא בה יש ערך של $0$ או $1$.

במהלך אחד, ניתן לבחור תא $(i, j)$ של מטריצה זו ולהפוך את הערכים בו ובכל התאים החולקים איתו צלע משותפת. באופן פורמלי, עבור כל תא $(s, t)$ ($1 \le s \le n, 1 \le t \le m$) המקיים $|s - i| + |t - j| \le 1$, מופעלת הטרנספורמציה $A_{s,t} \leftarrow 1 - A_{s,t}$.

מצא דרך לגרום למטריצה להכיל רק איברי אפס, או קבע שזה בלתי אפשרי.

קלט

השורה הראשונה מכילה שני מספרים שלמים $n$ ו-$m$ ($1 \le n, m \le 500$), המציינים את ממדי המטריצה.

השורה ה-$i$ מבין $n$ השורות הבאות מכילה מחרוזת בינארית בת $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.