This page is still under construction.

Parts of this page are still being built. What you see may change.

Frontier

Time limit1sMemory limit128 MB

Summary
Choose a subset of the polygon's vertices, in clockwise order, forming a convex polygon that strictly contains all given points, minimizing its perimeter.
Level

Hard8 of 10

Topics
Geometry, Dynamic programming, Greedy, Brute force
Solved
No attempts yet

Problem

The frontier of Lilliputia is a convex polygon with non-zero area. Its vertices are guard towers joined by straight walls. The frontier is long and expensive to maintain, so the government wants to shorten it. No new towers may be built: the revised frontier must reuse existing towers as its vertices.

Every day the guards inspect the frontier, walking clockwise from one tower to the next. The towers are numbered 11 through NN in this clockwise inspection order. The revision must keep this same inspection order, and the area enclosed by Lilliputia must stay non-zero. A valid new frontier is therefore any subset of the towers, taken in their original clockwise order, that forms a convex polygon of non-zero area (at least three towers that are not all collinear).

Lilliputia also has historical monuments that are a great source of national pride. Every monument must remain strictly inside Lilliputia; a monument may never lie on the frontier itself. Design the shortest possible frontier that keeps every monument strictly inside.

In the figure above (coordinates in kilometers), the original route 1 → 2 → 3 → 4 → 5 → 1 is 57.89 km long. With no monuments to protect, the shortest revision is 2 → 3 → 4 → 2, only 27.31 km. If the two monuments marked "A" and "B" must stay inside, the shortest valid frontier is 1 → 2 → 3 → 4 → 1, with length 51.78 km.

Input

The first line contains two integers NN and MM separated by a space. NN (3≤N≤503 \le N \le 50) is the number of guard towers on the frontier, and MM (0≤M≤10000 \le M \le 1000) is the number of historical monuments inside Lilliputia.

The next NN lines give the towers' coordinates in clockwise order, followed by MM lines giving the monuments' coordinates. Every coordinate is two integers XX and YY separated by a space, measured in kilometers, with absolute value at most 1000010000. All towers are at distinct points, and every monument lies strictly inside the original frontier.

Output

Print a single real number: the minimum possible length of the frontier, in kilometers, rounded to exactly two digits after the decimal point.

Examples2

  1. Example 1

    Input
    5 0
    8 9
    0 -7
    -8 -7
    -8 1
    -8 9
    
    Expected output
    27.31
    
  2. Example 2

    Input
    5 2
    8 9
    0 -7
    -8 -7
    -8 1
    -8 9
    -4 -3
    -1 -5
    
    Expected output
    51.78