QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Difficulty: [show] Hackable ✓

#8814. 几乎凸多边形 2

Statistics

这是关于 Kevin 和他的好朋友 Little Cyan Fish 的又一个故事。

Kevin 是国际凸多边形锦标赛(ICPC)的首席裁判。他为比赛提出了一个几何题目。然而,由于他在计算几何方面经验不足,他无法为该题的测试生成一个正确的凸多边形。

Kevin 对此感到非常难过。他的好朋友 Little Cyan Fish 安慰他说:“虽然你生成的数据不是凸多边形,但你可以称它为‘准凸多边形’!”

给定二维平面上的一个点集 $S$(包含至少 3 个点),其中任意两点不重合,且任意三点不共线。Little Cyan Fish 将一个多边形 $P$ 称为准凸多边形,当且仅当:

  • 多边形 $P$ 是简单多边形,即它的顶点互不相同,且多边形的任意两条边不相交或接触,除了相邻边在公共顶点处接触外。
  • 多边形的顶点属于 $S$,且 $S$ 中的所有点都在该多边形的内部或边界上。

令 $\mathbb{U}$ 为所有准凸多边形组成的集合。可以证明 $\mathbb{U}$ 是一个非空的有限集。因此,存在一个多边形 $R$,使得 $|R|$ 在 $\mathbb{U}$ 中的所有多边形中最小($|R|$ 为多边形 $R$ 的顶点数)。

Kevin 和 Little Cyan Fish 希望你计算满足 $|Q| \le |R|+2$ 的多边形 $Q \in \mathbb{U}$ 的数量。

输入格式

第一行包含一个整数 $n$ ($3 \le n \le 500$),表示点集 $S$ 中的点数。

接下来的 $n$ 行,第 $i$ 行包含两个整数 $x_i$ 和 $y_i$ ($-10^4 \le x_i, y_i \le 10^4$),表示 $S$ 中的一个点 $(x_i, y_i)$。

保证任意两点不重合,且任意三点不共线。

输出格式

输出一行,包含一个整数,表示满足条件的多边形 $Q$ 的数量。

样例

输入格式 1

7
0 2
1 0
1 3
2 5
3 0
3 3
4 2

输出格式 1

26

输入格式 2

5
4 0
0 0
2 1
3 3
3 1

输出格式 2

13

输入格式 3

3
0 0
3 0
0 3

输出格式 3

1

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.