QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 512 MB 満点: 100

#2263. 三视图

統計

你的朋友是一位设计“含像投影立方体”(Image-Containing Projection Cubes, ICPCs)的艺术家。ICPC 是一个边长为整数的晶体立方体。通过精密的激光加工工艺,其内部的一些区域被制成不透明。每个不透明区域都是一个与整数坐标对齐的单位立方体。

图 A.1 展示了样例输入 1 中的一个 ICPC。其中,绿色线条对应晶体立方体的棱,蓝色小立方体对应晶体内部不透明的立方体区域。

图 A.1. 样例输入 1 的 ICPC

ICPC 的设计初衷是通过三束垂直于其表面的平行光,投射出其内部不透明区域的轮廓。图 A.2 展示了该 ICPC 及其三个方向的轮廓。

图 A.2. 样例输入 1 的 ICPC 及其轮廓(点划线为垂直于左侧面的平行光的边缘)

你的任务是编写一个程序,判断是否存在一个 ICPC 能产生给定的轮廓。

输入格式

输入包含一组测试数据,格式如下:

$n$ $s_1$ $\vdots$ $s_n$ $t_1$ $\vdots$ $t_n$ $u_1$ $\vdots$ $u_n$

其中,$n$ 是 ICPC 的尺寸,为 $1$ 到 $100$ 之间的整数。

尺寸为 $n$ 的 ICPC 会产生三个 $n \times n$ 的明暗单元格轮廓。如果单元格被不透明单位立方体的阴影覆盖,则为暗色,否则为亮色。输入中从第二行开始的 $3n$ 行,每行包含 $n$ 个数字,表示 ICPC 的三个轮廓,其中 ‘0’ 代表亮色单元格,‘1’ 代表暗色单元格。这 $3n$ 行中至少有一个数字为 ‘1’。

首先是 $yz$ 平面上的轮廓数据,其中第一行 $s_1$ 给出了 $z$ 坐标最大时的轮廓单元格,按 $y$ 坐标顺序排列。接下来的行 $s_2, \dots, s_n$ 给出了 $z$ 坐标递减时的单元格。

接着是 $zx$ 平面上的轮廓数据,其中第一行 $t_1$ 给出了 $x$ 坐标最大时的单元格,按 $z$ 坐标顺序排列。接下来的行 $t_2, \dots, t_n$ 给出了 $x$ 坐标递减时的单元格。

最后是 $xy$ 平面上的轮廓数据,其中第一行 $u_1$ 给出了 $y$ 坐标最大时的单元格,按 $x$ 坐标顺序排列。接下来的行 $u_2, \dots, u_n$ 给出了 $y$ 坐标递减时的单元格。

下图展示了样例输入 1 中 ICPC 的三个轮廓。

图 A.3. 轮廓的 0-1 表示(样例输入 1)

输出格式

如果存在满足给定轮廓的 ICPC,输出 “Yes”,否则输出 “No”。

样例

样例输入 1

3
010
010
111
100
111
101
011
111
010

样例输出 1

Yes

样例输入 2

2
00
01
00
10
10
00

样例输出 2

Yes

样例输入 3

2
00
00
00
10
10
00

样例输出 3

No

样例输入 4

2
01
00
00
10
10
00

样例输出 4

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.