QOJ.ac

QOJ

时间限制: 5.0 s 内存限制: 2048 MB 总分: 100

#10590. 徒手攀岩

统计

Alex 是一位攀岩者,他正在计划下一次的徒手攀岩探险。这一次,他想要进行一次前所未有的全新攀登。在开始攀登之前,他想大致了解一下通往顶部的最短路径。

在攀岩中,Alex 使用手和脚抓住“支点”(holds),即墙上可以放置手或脚以保持身体稳定的点。

在这个简化的路线模拟中,Alex 被建模为一个单点,从该点延伸出 4 个长度最大为 1 的肢体。墙上的支点也是单点,任何肢体都可以使用它们,但一个支点在同一时间只能被一个肢体使用。为了保持安全,Alex 必须确保在攀登过程中的任何时刻,至少有 3 个肢体连接在支点上。

Alex 从坐标 $(0, 0)$ 出发,此时他连接在位于 $(-0.2, 0)$、$(0, 0)$ 和 $(0.2, 0)$ 的 3 个支点上,他试图到达的目标支点位于 $(T_x, T_y)$。请找出 Alex 从起始位置移动到能够将一个肢体放置在目标支点上所经过的最短路径长度。只要保持安全,Alex 的位置可以位于墙上的任何地方,包括 $y$ 坐标为负的位置。

数据范围

  • 任意两个支点之间的距离不会小于 $10^{-3}$。
  • 任意两个支点之间的距离不会在 $2 \pm 10^{-3}$ 的范围内。
  • 墙上不存在 Alex 能同时触及超过 6 个支点的位置。
  • 如果 Alex 的触及范围增加或减少最多 $10^{-6}$,最短路径的长度变化不会超过 $10^{-5}$。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 30$),表示支点的数量。 接下来的 $n$ 行包含两个浮点数,表示每个支点的 $x$ 和 $y$ 坐标 ($-10 \le x \le 10, 0 \le y \le 10$)。 浮点数将精确到小数点后 5 位。 输入的 3 个起始支点不包含在内。目标支点是给出的最后一个支点。

输出格式

输出通往目标支点的最短安全路径长度,如果不存在这样的路径,则输出 $-1$。如果你的答案与裁判答案的绝对误差或相对误差在 $10^{-4}$ 以内,则视为正确。

样例

输入 1

1
0.00000 1.50000

输出 1

0.5000000000

输入 2

1
0.00000 2.50000

输出 2

-1

输入 3

4
0.00000 0.50000
-0.80000 1.50000
0.80000 1.50000
0.70000 2.20000

输出 3

1.3647093219

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.