QOJ.ac

QOJ

実行時間制限: 6 s メモリ制限: 1024 MB 満点: 100

#4769. 让狗狗们保持距离

統計

尽管去年发生了不幸的事件,导致出现了十只小狗,但你再次被指派照顾邻居的狗。Shadow 和 Lydia 虽然是非常可爱的小狗,但今年你有严格的指示,必须一次只遛一只狗。然而,在夏天你还有其他事情要做!比如玩接球游戏和解决编程问题!一次只遛一只狗似乎效率太低了。

Picture by Cartman0052007 via Wikimedia Commons, cc by

Shadow 和 Lydia 都有各自偏爱且烂熟于心的散步路线。如果你只是把它们放出去,它们会沿着各自最喜欢的路线行走,最终到达各自的狗屋。问题解决了!

遗憾的是,你意识到如果你同时把两只狗放出去,让它们各自散步,它们可能会靠得太近。如果它们靠得太近,它们就会离开自己喜欢的路线去“找乐子”,而你无法确定是否还能为更多的小狗找到好人家。为了确保这种情况不会发生,你需要计算两只狗在各自散步时它们之间的最小距离。

两只狗同时出发,并保持完全相同的步速。一旦一只狗到达它的狗屋,它就会待在里面睡觉,因此我们不再需要担心它与另一只狗之间的距离,即使另一只狗可能还会继续走一段时间。注意,狗在进入狗屋的那一刻仍然是清醒的,进入后会立即睡着。

输入格式

输入的第一行包含一个整数 $n$ ($2 \le n \le 100\,000$),表示描述 Shadow 散步路线的点数。接下来的 $n$ 行每行包含 2 个整数,给出 Shadow 散步路线的 $x$ 和 $y$ 坐标。散步路线中任意两个连续的点至少在一个坐标上不同。所有坐标均为非负数且不超过 $10\,000$。类似地,下一行包含一个整数 $m$ ($2 \le m \le 100\,000$),表示描述 Lydia 散步路线的点数。接下来的 $m$ 行以相同的格式描述其散步路线。

输出格式

输出两只狗在散步期间的最小距离。数值应精确到绝对误差或相对误差不超过 $10^{-4}$。

样例

输入格式 1

2
0 0
10 0
2
30 0
15 0

输出格式 1

10

输入格式 2

5
10 0
10 8
2 8
2 0
10 0
9
0 8
4 8
4 12
0 12
0 8
4 8
4 12
0 12
0 8

输出格式 2

1.414213562373

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.