Traveling Salesperson in an Island

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

You are a salesperson at one of the ports in an island. You have to visit all the ports of the island and then come back to the starting port. Because you cannot swim and are scared of the sea, you have to stay on the land during your journey.

The island is modeled as a polygon on a two-dimensional plane. The polygon is simple, that is, its vertices are distinct and no two edges intersect or touch, other than consecutive edges which touch at their common vertex. In addition, no two consecutive edges are collinear. Each port in the island is modeled as a point on the boundary of the polygon. Your route is modeled as a closed curve that does not go outside of the polygon.

In preparation for the journey, you would like to compute the minimum length of a route to visit all the ports and return to the starting port.

입력

The input consists of a single test case of the following format.

nn mm

x_1x\_1 y_1y\_1

\vdots

x_nx\_n y_ny\_n

x_1x'\_1 y_1y'\_1

\vdots

x_mx'\_m y_my'\_m

The first line contains two integers nn and mm, which satisfy 3n1003 ≤ n ≤ 100 and 2m1002 ≤ m ≤ 100. Here, nn is the number of vertices of the polygon modeling the island, and mm is the number of the ports in the island. Each of the next nn lines consists of two integers x_ix\_i and y_iy\_i, which are the coordinates of the ii-th vertex of the polygon, where 0x_i10000 ≤ x\_i ≤ 1000 and 0y_i10000 ≤ y\_i ≤ 1000. The vertices of the polygon are given in counterclockwise order. Each of the mm following lines consists of two integers x_jx'\_j and y_jy'\_j, which are the coordinates of the jj-th port. The route starts and ends at (x_1,y_1)(x'\_1 , y'\_1). It is guaranteed that all the ports are on the boundary of the polygon and pairwise distinct.

출력

Output in a line the minimum length of a route to visit all the ports and return to the starting port. The relative error of the output must be within 10610^{-6}.

힌트

These samples are depicted in the following figures. The shortest routes are depicted by the thick lines. The gray polygons represent the islands. The small disks represent the ports in the islands. Note that the route does not have to be simple, i.e., the route may intersect or overlap itself as in the second sample, in which the same path between the two ports is used twice.

Figure J.1. Sample 1Figure J.2. Sample 2