QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 32 MB Puntuación total: 100

#596. 岛屿

Estadísticas

Byteasar 是幸福之洋中 Byteotia 岛的国王。该岛呈凸多边形,所有的城镇都位于海岸线上。其中一个城镇是 Byteotia 著名的首都 Byteburg。任意两个城镇之间都有一条沿线段连接的道路。一些连接不同城镇对的道路会发生相交,在每个这样的交点处都有一个十字路口。

Byteasar 的王位竞争对手 Bitratio 策划了一个卑劣的阴谋。当 Byteasar 从首都前往邻近城镇时,Bitratio 的人占领了 Byteburg。现在 Byteasar 必须尽快返回 Byteburg 以恢复他的统治。不幸的是,一些道路被 Bitratio 的游击队控制了。Byteasar 不能冒险使用这些道路,但他可以在十字路口穿过它们。不用说,他必须沿着道路行驶,因此只能在十字路口转弯,否则旅程将耗时太长。

Byteasar 的忠诚仆人已经告知他哪些道路是安全的。Byteasar 相信你的忠诚,因此委托你寻找从他当前所在的城镇到 Byteburg 的最短安全路线。

第一行包含两个整数 $n$ 和 $m$ ($3 \le n \le 100\,000$, $1 \le m \le 1\,000\,000$),用空格分隔,分别表示城镇的数量和被 Bitratio 游击队控制的道路数量。我们将城镇从 $1$ 到 $n$ 编号,从 Byteburg 开始沿海岸线顺时针排列。Byteasar 目前位于 $n$ 号城镇。接下来的 $n$ 行,每行包含一对整数 $x_i$ 和 $y_i$ ($-1\,000\,000 \le x_i, y_i \le 1\,000\,000$),用空格分隔,表示第 $i$ 号城镇的坐标。

接下来的 $m$ 行,每行包含一对整数 $a_j$ 和 $b_j$ ($1 \le a_j < b_j \le n$)。该对数据表示连接 $a_j$ 和 $b_j$ 的道路被 Bitratio 的游击队控制。每一对都是唯一的。你可以假设在每个测试数据集中,Byteasar 都能到达 Byteburg。

你的程序应向标准输出打印一个浮点数:从 $n$ 号城镇到 Byteburg 的最短安全路线长度。输出结果与正确答案的绝对误差不得超过 $10^{-5}$。

样例

输入 1

6 9
-12 -10
-11 6
-4 12
6 14
16 6
18 -2
3 4
1 5
2 6
2 3
4 5
3 5
1 3
3 6
1 6

输出 1

42.0000000000

说明

Byteasar 应遵循的路线是从 6 号城镇出发前往 4 号城镇方向,然后在连接 2 号和 5 号城镇的道路处转弯,最后沿着连接 Byteburg 和 4 号城镇的道路行驶。

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.