QOJ.ac

QOJ

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

#21287. 解锁方块

Statistics

一个鲜为人知的事实是,奶牛喜欢谜题!Bessie 生日时,Farmer John 送她一个有趣的机械谜题。谜题由三个实体物体组成,每个由 $1\times1$ 单位方格粘合而成。每个物体的形状都“连通”:从其任一方格出发,沿北、南、东、西方向经过物体内的方格,可以到达其任意其他方格。

物体可以反复向北、南、东或西滑动一个单位来移动。目标是移动它们使其分离,即包围盒两两不相交。给定三个物体的形状和位置,请帮 Bessie 判断能否分离。无法分离的布局称为锁住。

fig_unlock.png

[注意:只对输出随机猜测的程序可能被取消资格,得零分。]

输入格式

  • 第 1 行:空格分隔的三个整数 $N1$、$N2$、$N3$,分别表示物体 1、2、3 包含的单位方格数量。
  • 第 $2\ldots1+N1$ 行:每行描述物体 1 内一个方格西南角的 $(x,y)$ 坐标。所有坐标在范围 $0\ldots9$ 内。
  • 第 $2+N1\ldots1+N1+N2$ 行:每行描述物体 2 内一个方格西南角的 $(x,y)$ 坐标。所有坐标在范围 $0\ldots9$ 内。
  • 第 $2+N1+N2\ldots1+N1+N2+N3$ 行:每行描述物体 3 内一个方格西南角的 $(x,y)$ 坐标。所有坐标在范围 $0\ldots9$ 内。

输出格式

  • 第 1 行:若物体能相互分离,输出 1;若锁住,输出 0。

样例

输入格式 1

12 3 5
0 0
1 0
2 0
3 0
3 1
0 1
0 2
0 3
0 4
1 4
2 4
3 4
2 1
2 2
1 2
2 3
3 3
4 3
4 4
4 2

输出格式 1

1

说明

物体 1 由 12 个方格组成,物体 2 由 3 个组成,物体 3 由 5 个组成。形状如上图所示。

题目作者:Brian Dean,2012

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.