QOJ.ac

QOJ

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

#12544. 儿童设计儿童

Statistics

Kevin 和 Kimberly 的额头上都有雀斑。

他们都在纸上画出了自己的雀斑图案。每张图都是一个矩形的“像素”阵列:每个单元格要么有雀斑,要么没有。

他们开玩笑地提议,当他们长大结婚并生下孩子时,孩子的雀斑图案将通过以下过程产生: Kevin 和 Kimberly 的图片分别进行平移,然后对于每个单元格,如果且仅当父母双方中恰好有一方在该位置有雀斑时,孩子在该位置才有雀斑。

现在他们想知道,是否存在一种平移方式,使得他们的孩子能得到特定的雀斑图案(例如,闪电形状),如果有,这种平移方式是什么。

输入格式

第一行包含两个整数 $h_1$ 和 $w_1$ ($1 \le h_1, w_1 \le 1000$),表示 Kevin 雀斑图片的高度和宽度。接下来的 $h_1$ 行,每行包含 $w_1$ 个字符 '' 或 '.'。字符 '' 表示有雀斑,'.' 表示没有。

接下来的行包含 Kimberly 的图片,格式相同。其高度 $h_2$ 和宽度 $w_2$ 遵循相同的约束。

保证 Kevin 和 Kimberly 至少各有一个雀斑。

接下来的行包含他们想要的孩子图片,格式相同。其尺寸 $h_3$ 和 $w_3$ 也遵循相同的约束。

输出格式

如果可以产生目标图案,第一行输出 “YES”,否则输出 “NO”。

如果答案为肯定,则在第二行输出两个整数 $x$ 和 $y$,含义如下:如果你将两张图片重叠,使得它们的左上角重合,然后将 Kimberly 的图片向右移动 $x$ 个单元格(负数表示向左移动),向下移动 $y$ 个单元格(负数表示向上移动),接着应用上述过程,所得结果图片可以通过平移与输入文件中的第三张图片重合。

样例

输入 1

3 3
..*
.*.
*.*
3 3
**.
..*
.*.
5 2
.*
*.
**
.*
*.

输出 1

YES
0 2

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.