QOJ.ac

QOJ

时间限制: 7.0 s 内存限制: 1024 MB 总分: 100

#8019. Wowoear

统计

Wowo 是一位独自完成过许多危险旅程的探险家,他的足迹遍布森林、沙漠甚至冰川。上海 ICPC(上海程序作弊邀请赛)委员会邀请 Wowo 作为他们新跑步赛道的测试员。

该赛道可以描述为一条二维简单折线 $(p_1, \dots, p_n)$。换句话说,赛道由 $n-1$ 条线段 $(p_1, p_2), \dots, (p_{n-1}, p_n)$ 组成。除了两条相邻线段 $(p_i, p_{i+1})$ 和 $(p_{i+1}, p_{i+2})$ 在点 $p_{i+1}$ 处相交外,这些线段互不相交。任意两条相邻线段的方向都不同。委员会希望 Wowo 按照顺序沿着线段 $(p_1, p_2), \dots, (p_{n-1}, p_n)$ 从 $p_1$ 跑到 $p_n$。

然而,Wowo 有一个智能设备,可以在一段时间内入侵委员会的系统。Wowo 可以选择赛道上的两个点 $a$ 和 $b$,并沿着线段 $(a, b)$ 直接从 $a$ 跑到 $b$。点 $a$ 和 $b$ 既可以是某个 $p_i$ ($1 \le i \le n$),也可以是某条线段 $(p_i, p_{i+1})$ ($1 \le i < n$) 上的任意点。在到达 $a$ 之前和离开 $b$ 之后,Wowo 必须沿着原始赛道跑步。Wowo 不想被发现作弊,因此他决定线段 $(a, b)$ 除了在 $a$ 和 $b$ 处外,不能与赛道的任何线段相交或接触。请帮助 Wowo 明智地选择 $a$ 和 $b$,并输出他使用智能作弊设备从 $p_1$ 跑到 $p_n$ 所需的最短距离。

输入格式

第一行包含一个整数 $n$,表示跑步赛道上的点数 ($2 \le n \le 200$)。 第 $i+1$ 行 ($1 \le i \le n$) 包含两个整数 $x$ 和 $y$,用空格分隔,表示点 $p_i$ 的坐标 ($-1000 \le x, y \le 1000$)。

保证线段互不相交,除了两条相邻线段 $(p_i, p_{i+1})$ 和 $(p_{i+1}, p_{i+2})$ 在点 $p_{i+1}$ 处相交。换句话说,对于任何满足 $1 \le i < j < n$ 的整数 $i, j$,以下关系成立: $$(p_i, p_{i+1}) \cap (p_j, p_{j+1}) = \begin{cases} \emptyset & i \neq j-1 \\ \{p_{j}\} & i = j-1 \end{cases}$$ 其中 $(s, t)$ 表示从 $s$ 到 $t$ 的线段上的所有点(包含 $s$ 和 $t$)。

保证每条线段的长度都不为零。换句话说,对于任何整数 $i \in [1, n)$,都有 $p_i \neq p_{i+1}$。

保证相邻线段不共线。换句话说,对于任何整数 $i \in [1, n-2]$ 和任何实数 $\lambda$,都有 $p_i - p_{i+1} \neq \lambda(p_{i+1} - p_{i+2})$。

输出格式

输出 Wowo 需要跑步的最短距离。如果你的答案的绝对误差或相对误差不超过 $10^{-6}$,则被视为正确。

样例

样例输入 1

5
0 0
1 10
2 0
3 10
4 0

样例输出 1

22.099751242242

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.