K. Service

K. Service

Time Limit: 1000MS

Description

There is a large and beautiful polygon pond in HY city. Lina wants to offer a service which can tell people how to travel around the pond easier. She entrusts you to finish this job. People can walk on the edge of the polygon pond.She will tell you the coordinates of each vertex in the pond and two points, A and B. You should calculate the minimum distance travel from A to B without cross the polygon pond.

Input

One or more test,First line contains only one integer n, means the number of vertexes in the polygon. There follows n lines each contains two integers means the coordinate of the vertex. The vertexes are given counter-clockwise.

The last line contains four integers which are the coordinates of point A and point B (Ax, Ay, Bx, By). Those two points will not be inside the polygon.

You should pay attention to that the lake may be a concave polygon.

Output

You should output one line contains only one real number, which is the minimum distance travelling from A to B without cross the polygon lake. The answer should be rounded to three decimals.

 Sample Input

Sample Output

4

0 0

1 0

1 1

0 1

0 0 2 0

 

2.000

 

 

 思路:因为给出的两点在最外层故在求凸包时也把它们包含在内然后在从给出的一点求距离直至另一点

你可能感兴趣的:(service)