QOJ.ac

QOJ

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

#4796. Tris

Statistics

你拥有一些多米诺骨牌状的拼图块。可能的拼图块类型如下:

注意,总共只有四种类型,你可以旋转或翻转任何拼图块以供使用。你需要将所有拼图块放置在一个最大为 $800 \times 800$ 的矩阵中,使得它们构成一个单一的、不自交的环。形式化地,这意味着:

  • 所有拼图块必须完全位于矩阵内并与网格对齐。
  • 任意两个拼图块不得重叠。
  • 如果某个矩阵单元格被拼图块占据,则其四个相邻单元格中必须恰好有两个也被占据。
  • 所有被占据的单元格是连通的。换句话说,你可以只通过移动到相邻的被占据单元格,从任何一个被占据的单元格到达另一个被占据的单元格。
  • 环的“内部”必须是一个单一的 4-连通区域。

输入格式

输入包含一行,包含四个整数:每种类型拼图块的数量(按图中所示顺序)。保证每个数字至少为 2 且至多为 100,并且保证至少存在一个有效的答案。

输出格式

输出的第一行必须包含两个整数 $N$ 和 $M$ ($N, M \le 800$),表示矩阵的行数和列数。接下来的行必须按以下格式描述矩阵:

  • 矩阵必须包含 0 到拼图块总数之间的整数(包含边界值)。
  • 被同一个拼图块占据的单元格必须具有相同的值。
  • 被不同拼图块占据的单元格必须具有不同的值。
  • 未被任何拼图块占据的单元格必须赋值为 0。

如果存在多个有效答案,输出其中任意一个即可。

样例

输入 1

3 4 3 4

输出 1

11 6
0 1 2 4 4 4
1 1 0 0 0 3
8 0 0 0 3 3
8 0 0 0 9 0
8 0 0 0 9 9
10 0 0 0 0 13
10 0 0 0 0 11
12 0 0 0 0 11
12 0 0 0 0 14
6 0 0 0 0 7
6 5 5 5 7 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.