QOJ.ac

QOJ

Límite de tiempo: 4 s Límite de memoria: 2048 MB Puntuación total: 100

#7693. 凸包扩展

Estadísticas

Hugh Klidd 博士是一位几何学专家,最近他沉迷于凸包的研究。回想一下,对于 $x-y$ 平面上的点集,凸包是包含所有这些点的最小凸多边形。(凸多边形具有以下性质:对于多边形上或内部的任意两点,连接这两点的线段完全位于多边形上或内部。)Klidd 博士刚刚计算了一个点集 $S$ 的凸包,他将其记为 $H(S)$,并对结果非常满意:

  • 凸包有 $n \ge 3$ 个顶点
  • 每个顶点都有整数坐标
  • 凸包的任意三个顶点都不共线,即不在同一条直线上

不过,Klidd 博士雄心勃勃,他希望这个凸包能够继续增长。具体来说,他正在寻找一个“扩展点”,即满足以下条件的点 $p = (x, y)$:

  1. $x$ 和 $y$ 均为整数
  2. 如果令 $S' = S \cup \{p\}$(即在 $S$ 中加入 $p$),则 $S'$ 的凸包(即 $H(S')$)有 $n + 1$ 个顶点
  3. 这 $n + 1$ 个顶点中任意三个都不共线

换句话说,扩展点在保持凸包所有优良性质的同时,将凸包的顶点数增加了 1。对于大多数凸包 $H(S)$,Klidd 博士通常能找到至少一个扩展点,但他想知道总共有多少个可选的扩展点。他推测存在一种有效的方法来计算扩展点的数量,但由于从未修过算法课程,他向你寻求帮助。

图 C.1:样例输入 1 的扩展点示意图

输入格式

输入的第一行包含一个整数 $n$,表示 Klidd 博士初始凸包的顶点数($3 \le n \le 50$)。接下来有 $n$ 行,每行包含两个空格分隔的整数,表示其中一个顶点的 $x$ 和 $y$ 坐标($-1\,000 \le x, y \le 1\,000$)。这 $n$ 个点各不相同,任意三点不共线,且按逆时针顺序给出。

输出格式

如果输入中指定的凸包的扩展点数量是无限的,输出 “infinitely many”。否则,输出扩展点的数量。

样例

输入 1

5
0 2
-2 0
-1 -3
1 -3
2 1

输出 1

23

输入 2

4
-7 -7
7 -7
7 7
-7 7

输出 2

infinitely many

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.