QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 256 MB Total points: 100

#12727. 数字加法

Statistics

Deidra 正在进行列式加法。她将两个非负整数加数上下排列,并在左侧补零使它们长度相等,然后计算它们的和(例如 $77 + 05 = 82$)。如果和的长度超过了加数(由于进位,例如 $96 + 07 = 103$),她会在每个加数的最前面补一个零($096 + 007 = 103$)。只要三个数字的长度相同,她允许使用不必要的先导零($007 + 004 = 011$)。

此外,Deidra 有一台自制的印刷机。她决定在不打印加号或横线的情况下,使用以下标准字体打印她的加法算式:

不幸的是,她弄乱了间距,所有的数字都以以下方式重叠打印在一起。本应水平相邻的数字,其打印位置使得左侧数字的右侧两个段与右侧数字的左侧两个段重合。本应垂直相邻的数字,其打印位置使得上方数字的下半部分(一个包含 4 个段的正方形)与下方数字的上半部分重合。

当一个或多个黑色段被打印在同一位置时,结果看起来是黑色的。当该位置只有空白段时,结果看起来是白色的。

给定最终的图像,请找到一个能产生该图像的正确加法算式,或者判断不存在这样的算式。

输入格式

第一行包含一个整数 $w$ ($1 \le w \le 100$),表示 Deidra 加法算式的宽度(每行数字的个数)。

接下来的 9 行包含用错误间距打印的图像描述。每行包含 $w$ 或 $w + 1$ 个数字。'1' 表示黑色段,'0' 表示白色段。偶数行以空格开头。详见样例。

输出格式

如果不存在有效的加法算式,输出 “NO”。

否则,输出一个能产生给定图像的有效加法算式。输出应包含三行,每行包含 $w$ 个数字。

如果有多个解,输出其中任意一个。

样例

样例输入 1

2
1 1
0 1 1
1 0
0 1 1
1 1
0 1 1
1 0
0 1 1
0 0

样例输出 1

37
34
71

样例输入 2

1
1
0 1
1
1 1
1
1 1
1
0 1
0

样例输出 2

2
2
4

样例输入 3

1
1
1 0
1
1 1
1
1 1
1
0 1
0

样例输出 3

NO

说明

第一个样例在题目描述中已有图示。

在第二个样例中,加法 $7 + 0 = 7$ 也能产生相同的图像。

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.