#P3493. [POI 2009] WSP-Island

    ID: 2548 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>计算几何2009POISpecial Judge半平面交

[POI 2009] WSP-Island

Description

Byteasar is the king of Byteotia, an island in the Ocean of Happiness. The island is convex, and all the towns of Byteotia are located on the shore. One of these towns is Byteburg, the capital of Byteotia.

Every pair of towns is connected by a straight road that follows the line segment between the towns. If two such roads intersect, there is a crossroad at the intersection, and one may freely pass through it.

Some roads are controlled by Bitratio’s guerrilla. Byteasar cannot travel along such roads, but he may cross them at crossroads. He must travel only along roads and may turn only at towns or crossroads.

The towns are numbered from 11 to nn starting from Byteburg and moving clockwise along the shore. Byteasar is currently in town ss. Find the length of the shortest safe route from town ss to Byteburg (town 11).

Description

Input Format

  • The first line contains two integers nn and mm — the number of towns and the number of roads controlled by the guerrilla.
  • The second line contains one integer ss — the index of the town where Byteasar is currently located.
  • Each of the next mm lines contains two integers aia_i and bib_i (1ai<bin1 \le a_i < b_i \le n), denoting a road between towns aia_i and bib_i that is controlled and thus cannot be used for travel (but may be crossed at crossroads).

Output Format

Print a single floating-point number: the length of the shortest safe route from town ss to Byteburg (town 11). The absolute error of your answer must be at most 10410^{-4}.

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

42.0000000000

Hint

Special judge.

Translated by ChatGPT 5