QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#7846. 冰川旅行

Statistics

冰川是缓慢流动的巨大冰河,其中布满了隐藏在薄雪下的裂缝,等待着毫无防备的步行者踏入并坠落。为了降低危险,徒步旅行者通常会结队,并用粗绳子系在一起,以减少坠落带来的后果——如果一个人掉进去了,另一个人或许还能在安全距离外拉住他们。

今天,你和你的同伴系着绳子穿越冰川。你们的计划是沿着完全相同的路线,以相同的速度行进,第一位先行出发,第二位在你们之间恰好相距 $s$ 米时开始沿路径行进。如果你们走的是完全笔直的路径,那么你们在任何时候都将保持恰好 $s$ 米的距离。

图 G.1:从上方俯瞰第 2 个样例中路径的示意图。这也可以看作是某人掉进裂缝的特别“节日”图示。

然而,由于你在避开障碍物时路径是蜿蜒曲折的,这意味着你们并不总是能保持恰好 $s$ 米的距离。当你们两人都在路径上行走时,你们之间实际达到的最近距离是多少?

输入格式

  • 第一行包含一个实数:沿路径的间隔距离 $s$ ($1 \le s \le 1000$)。
  • 第二行包含路径上的点数 $n$ ($2 \le n \le 10^6$)。
  • 接下来 $n$ 行,第 $i$ 行包含一对整数,表示轨道上第 $i$ 个点的坐标 $x_i, y_i$ ($-10^6 \le x, y \le 10^6$),单位为米,相对于原点。

轨道上每两个相邻的点都是不同的,尽管轨道可能会交叉或重复自身。保证轨道的总长度至少为 $s$。

输出格式

输出两位步行者在路径上任意一点的最小距离,忽略第一位步行者走完之后或第二位步行者开始之前的时间。

输出的绝对误差或相对误差不得超过 $10^{-4}$。

样例

输入 1

5
4
20 0
10 0
10 10
0 10

输出 1

3.5355339

输入 2

3.16227766
9
-2 4
2 4
3 1
4 4
5 1
6 4
10 2
6 1
7 4

输出 2

1

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.