QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 2048 MB Total points: 100

#5101. 水晶侧风

Statistics

你所在的科研团队正在开发一种在分子水平上对晶体结构进行成像的新技术。该技术涉及在晶体表面以不同角度吹送极细的风,以探测边界(由暴露在风中的分子指示)。这一过程会在不同的风向下重复进行,并记录下每个方向观察到的边界。你的团队已经收集了数据,但正如应用科学中常见的情况一样,现在必须开始真正的工作——分析。

对于给定的晶体,你将收到风吹过表面的方向,以及每次风所遇到的所有边界的位置。对于风向为 $(w_x, w_y)$ 的风,边界定义为满足以下条件的位置 $(x, y)$:在该位置 $(x, y)$ 存在一个分子,且在位置 $(x - w_x, y - w_y)$ 不存在分子。注意,由于技术原因,$w_x$ 和 $w_y$ 不一定互质。

这些数据可能无法唯一确定晶体的结构。你必须找出符合观测结果的分子数量最少和最多的两个唯一结构。

例如,在第一个样例输入中,有 9 个不同的分子被给定的风直接探测到。在位置 $(3, 3)$ 处必须有一个分子,否则 $(4, 2)$ 将会是第三次风的边界。出于同样的原因,在 $(4, 4)$ 和 $(5, 5)$ 处也必须有分子。不能再有其他分子,因为它们会导致某些风产生额外的观测结果。

输入格式

输入的第一行包含三个整数 $d_x$、$d_y$ 和 $k$,其中 $d_x$ 和 $d_y$ ($1 \le d_x, d_y \le 10^3$) 是晶体结构的最大尺寸,$k$ ($1 \le k \le 10$) 是风吹过晶体的次数。

接下来的 $k$ 行,每行指定一次风的数据。这些行均以两个整数 $w_x$ 和 $w_y$ ($-d_x \le w_x \le d_x$ 且 $-d_y \le w_y \le d_y$,且不同时为零) 开头,表示风的方向。接着是一个整数 $b$ ($0 \le b \le 10^5$),表示该风遇到的边界数量。该行最后包含 $b$ 个不同的整数对 $x, y$ ($1 \le x \le d_x$ 且 $1 \le y \le d_y$),列出每个观察到的边界。

你可以假设输入与至少一种晶体结构一致,且在指定尺寸之外不存在分子。

输出格式

输出两个晶体结构的文本表示,中间用空行隔开。每个结构都有 $d_y$ 行,每行 $d_x$ 个字符,左上角对应位置 $(1, 1)$。第一个是符合观测结果的分子数量最少的结构,第二个是分子数量最多的结构。使用 '#' 表示存在分子的位置,使用 '.' 表示不存在分子的位置。

样例

样例输入 1

6 6 3
1 1 3 3 1 1 3 2 2
0 2 6 3 1 1 3 2 2 6 4 5 3 4 2
1 -1 4 1 3 2 4 3 5 4 6

样例输出 1

..#...
.#.#..
#.#.#.
.#.#.#
..#.#.
...#..

..#...
.#.#..
#.#.#.
.#.#.#
..#.#.
...#..

样例输入 2

5 4 2
1 0 6 1 1 4 1 2 2 5 2 2 3 3 4
0 -1 7 1 1 4 1 5 2 2 3 3 4 4 4 5 4

样例输出 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.