QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#14830. 沙丘冲刺

الإحصائيات

你报名参加了 Dune Dash,这是一场穿越沙漠的越野赛。一切都很顺利——除了在兴奋之余,你忘记启动 StrideTrack,这是一款记录你跑步距离的应用程序。现在你手里只有官方的检查点位置,但不知道你通过它们的顺序。

正式地,比赛由 $N$ 个检查点组成,每个检查点由其在欧几里得平面上的坐标给出。你不知道它们被访问的顺序,但组织者设计路线是为了防止任何人偏离路线。特别是,如果 $q_1, q_2, \dots, q_N$ 是沿比赛路线正确排序的检查点列表,那么对于任意三元组 $i < j < k$,都满足:

$$\text{dist}(q_i, q_k) > \max(\text{dist}(q_i, q_j), \text{dist}(q_j, q_k))$$

其中 $\text{dist}(p, q)$ 表示点 $p$ 和 $q$ 之间的欧几里得距离。你的任务是确定比赛的总长度。

图 D.1:样例 2 的示意图。虚线表示比赛的路线。

输入格式

第一行包含一个整数 $N$ ($2 \le N \le 2 \cdot 10^5$)。

接下来的 $N$ 行,每行包含两个整数 $x_i$ 和 $y_i$ ($-10^9 \le x_i, y_i \le 10^9$)。这些是每个检查点的坐标。

检查点不一定是按照比赛中被访问的顺序给出的。

保证存在一种检查点的排序,使得它们满足上述距离要求。

输入中给出的 $N$ 个点互不相同。

输出格式

输出一个浮点数,表示比赛的总长度。如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则视为正确。

样例

输入样例 1

3
1 0
0 0
1 1

输出样例 1

2.0

输入样例 2

10
-1 -7
-1 -11
0 -9
2 2
1 -2
2 -1
3 1
-1 -5
0 -3
-3 -11

输出样例 2

17.186912597118443

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.