QOJ.ac

QOJ

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

#6799. 道路建设

Statistics

在 Coffee Chicken 王国有 $n + m$ 个城镇,它们可以看作二维平面上的 $n + m$ 个整点坐标 $(x_i, y_i)$。其中 $n$ 个城镇属于 Acesrc,另外 $m$ 个城镇属于 Roundgod。

现在 Acesrc 和 Roundgod 都想在各自的城镇之间修建直线道路,并且他们希望各自的城镇都是连通的,这意味着任意两个同属一方的城镇之间都存在一条路径。显然,我们只需要 $n + m - 2$ 条道路就能实现这一目标。此外,Acesrc 和 Roundgod 希望在这 $n + m - 2$ 条道路中,除了城镇所在位置外,没有任何道路相交。

现在希望你提供一个施工方案。

输入格式

第一行包含两个整数 $n, m$ ($n > 1, m > 1, n + m \le 3000$)。

接下来的 $n$ 行描述 Acesrc 的城镇,每行包含两个整数 $x, y$ ($0 \le x, y \le 10^9$),表示坐标。它们的编号分别为 $1 \sim n$。

接下来的 $m$ 行描述 Roundgod 的城镇,每行包含两个整数 $x, y$ ($0 \le x, y \le 10^9$),表示坐标。它们的编号分别为 $1 \sim m$。

这 $n + m$ 个城镇的坐标互不相同。我们还保证其中任意三点不共线。

输出格式

请总共输出 $n + m - 2$ 行,前 $n - 1$ 行表示 Acesrc 城镇的施工方案,后 $m - 1$ 行表示 Roundgod 城镇的施工方案。对于施工方案的每一行,请输出两个整数 $x, y$,表示连接城镇 $x$ 和 $y$ 的一条直线道路。

如果无法找到任何有效的施工方案,请输出 Impossible

样例

输入格式 1

2 3
0 0
1 1
1 0
0 1
2 3

输出格式 1

2 1
1 3
3 2

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#329EditorialOpen题解jiangly2025-12-14 07:06:51View

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.