QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#9177. 字符串与钉子

Estadísticas

木板上有 $n$ 枚钉子,坐标均为整数。你有一根绳子,它围住了所有的钉子,并被拉紧形成一个包围这些点的最小闭合曲线。你需要按照以下规则逐一移除钉子:

首先,将绳子拉紧,使其包围剩余的钉子。然后,你可以选择任何一根被拉紧的绳子所接触的钉子(即绳子接触该钉子处形成的内角 $< 180^\circ$)并将其移除。你需要尝试重复此过程,直到只剩下一枚钉子为止。

请判断是否可以通过重复上述过程直到只剩下一枚钉子,如果可以,请给出移除钉子的顺序。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 200\,000$),表示输入中点的数量。 接下来的 $n$ 行,每行包含两个整数 $x$ 和 $y$ ($0 \le x, y \le 10^9$),表示木板上钉子的坐标。 保证没有两枚钉子位于木板上的同一位置。

输出格式

如果可以按照规则移除钉子直到只剩下一枚,输出 “YES”;否则,输出 “NO”。如果答案为 “YES”,则在接下来的行中输出移除过程。 在接下来的 $n - 1$ 行中,每行输出两个整数 $x$ 和 $y$ ($0 \le x, y \le 10^9$),表示你当前想要移除的钉子的坐标。 如果存在多种方案,输出任意一种即可。

样例

样例输入 1

3
1 1
2 4
3 1

样例输出 1

YES
1 1
2 4

样例输入 2

1
1000000000 0

样例输出 2

YES

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.