Under construction

Still being built. Things may change

Joining Capitals

Time limit2sMemory limit512 MB

Summary
Connect all capitals with degree exactly one through Steiner points (non-capitals) at minimum Euclidean total cost.
Level

Hard8 of 10

Topics
Graph, Minimum spanning tree, Geometry, Dynamic programming
Solved
No attempts yet

Problem

A distant kingdom has N cities, of which K are capitals. King Richard wants to build transmission lines, each connecting two cities. There must be a path, that is, a sequence of transmission lines, between any pair of capitals.

Each transmission line has a cost, which is the Euclidean distance between the cities it connects. The king is stingy, so he wants the transmission lines built so that the total cost (the sum of the line costs) is as small as possible.

Part A of the figure shows an example kingdom with N = 10 cities, of which K = 4 are capitals. The chief engineer presented the king with the solution in part B, which does minimize the total cost. But the king did not like seeing a capital with more than one transmission line. He therefore imposed a new restriction: a capital may be connected to only one other city. After working hard, the chief engineer presented the new solution shown in part C of the figure. He is not sure whether that solution is optimal, and he needs your help.

Given the coordinates of the cities, write a program that computes the minimum possible total cost of building transmission lines so that every pair of capitals is connected by a path and every capital is connected to only one city.

Input

The first line of the input contains two integers, N and K, with 4 ≤ N ≤ 100 and 3 ≤ K < min(10, N), giving the number of cities and the number of capitals. Each of the next N lines contains two integers X and Y, with −1000 ≤ X, Y ≤ 1000, giving the coordinates of one city. The first K cities are the capitals. No two cities have the same coordinates.

Output

Print one line containing a real number with 5 decimal places, the minimum total cost of building the transmission lines under the constraints above.

Examples2

  1. Example 1

    Input
    6 4
    -20 10
    -20 -10
    20 10
    20 -10
    -10 0
    10 0
    
    Expected output
    76.56854
    
  2. Example 2

    Input
    22 9
    -3 -25
    0 -6
    -1 -9
    2 -21
    -5 -19
    0 -23
    -2 24
    -4 37
    -3 33
    -3 -12
    2 39
    3 -49
    -3 -26
    2 24
    5 3
    -4 -9
    -2 -9
    -4 8
    3 -33
    -2 31
    -1 -13
    0 2
    
    Expected output
    95.09318