QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 256 MB Puntuación total: 100

#6436. 派蒙多边形

Estadísticas

Paimon 在平面上放置了 $(n + 1)$ 个不同的点,其中一个是特殊点 $O = (0, 0)$,其余点组成的集合记为 $\mathbb{S}$。

如果一个点集 $U$ 满足 $|U| \ge 3$,且 $U$ 中的所有点都恰好位于由 $U$ 构建的凸包上,且没有三点共线,则称该点集 $U$ 为严格凸集。

你需要将 $\mathbb{S}$ 划分为两个集合 $\mathbb{A}$ 和 $\mathbb{B}$,使得:

  • $\mathbb{A} \cap \mathbb{B} = \emptyset$。
  • $\mathbb{A} \cup \mathbb{B} = \mathbb{S}$。
  • $|\mathbb{A}| \ge 2, |\mathbb{B}| \ge 2$。
  • 点集 $\mathbb{A} \cup \{O\}$ 是一个严格凸集,记其凸包为 $C_{\mathbb{A} \cup \{O\}}$。
  • 点集 $\mathbb{B} \cup \{O\}$ 是一个严格凸集,记其凸包为 $C_{\mathbb{B} \cup \{O\}}$。
  • $C_{\mathbb{A} \cup \{O\}}$ 和 $C_{\mathbb{B} \cup \{O\}}$ 的轮廓(边)仅在点 $O$ 处相交。也就是说,只有点 $O$ 同时位于 $C_{\mathbb{A} \cup \{O\}}$ 和 $C_{\mathbb{B} \cup \{O\}}$ 的轮廓上。

请帮助 Paimon 最大化这两个凸包周长之和。即找到一个合法的划分 $\mathbb{A}$ 和 $\mathbb{B}$,使得 $(L(C_{\mathbb{A} \cup \{O\}}) + L(C_{\mathbb{B} \cup \{O\}}))$ 最大,其中 $L(\text{polygon})$ 表示该多边形的周长。

输入格式

输入包含多组测试数据。第一行包含一个整数 $T$,表示测试数据的组数。对于每组测试数据:

第一行包含一个整数 $n$ ($4 \le n \le 5 \times 10^5$),表示 $\mathbb{S}$ 中的点数。

接下来的 $n$ 行,第 $i$ 行包含两个整数 $x_i$ 和 $y_i$ ($-10^9 \le x_i, y_i \le 10^9, (x_i, y_i) \neq (0, 0)$),表示 $\mathbb{S}$ 中第 $i$ 个点的位置。

保证同一组测试数据中的点两两不同。然而,可能存在三点共线的情况。

保证所有测试数据的 $n$ 之和不超过 $10^6$。

输出格式

对于每组测试数据,输出一行,包含一个数字,表示最大总周长。如果不存在合法的划分,则输出 “0”。

如果你的答案与标准答案的相对误差或绝对误差小于 $10^{-6}$,则会被接受。

样例

输入格式 1

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

输出格式 1

17.2111025509
36.6326947621
0.0000000000

说明

下图展示了第一个样例测试数据的合法划分(左)和非法划分(右)。

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.