atcoder#ABC274E. [ABC274E] Booster

[ABC274E] Booster

Score : 500500 points

Problem Statement

In a two-dimensional plane, there are NN towns and MM chests. Town ii is at the coordinates (Xi,Yi)(X_i,Y_i), and chest ii is at the coordinates (Pi,Qi)(P_i,Q_i).

Takahashi will go on a trip where he starts at the origin, visits all NN towns, and then returns to the origin. It is not mandatory to visit chests, but each chest contains an accelerator. Each time he picks up an accelerator, his moving speed gets multiplied by 22.

Takahashi's initial moving speed is 11. Find the shortest time needed to complete the trip.

Constraints

  • 1N121 \leq N \leq 12
  • 0M50 \leq M \leq 5
  • 109Xi,Yi,Pi,Qi109-10^9 \leq X_i,Y_i,P_i,Q_i \leq 10^9
  • (0,0)(0,0), (Xi,Yi)(X_i,Y_i), and (Pi,Qi)(P_i,Q_i) are distinct.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN MM

X1X_1 Y1Y_1

\vdots

XNX_N YNY_N

P1P_1 Q1Q_1

\vdots

PMP_M QMQ_M

Output

Print the answer. Your output will be considered correct if the absolute or relative error from the judge's answer is at most 10610^{-6}.

2 1
1 1
0 1
1 0
2.5000000000

Here is one optimal way to complete the trip.

  • Go the distance 11 from the origin to chest 11 at a speed of 11, taking a time of 11.
  • Go the distance 11 from chest 11 to town 11 at a speed of 22, taking a time of 0.50.5.
  • Go the distance 11 from town 11 to town 22 at a speed of 22, taking a time of 0.50.5.
  • Go the distance 11 from town 22 to the origin at a speed of 22, taking a time of 0.50.5.
2 1
1 1
0 1
100 0
3.4142135624

Here is one optimal way to complete the trip.

  • Go the distance 1.411.41\ldots from the origin to town 11 at a speed of 11, taking a time of 1.411.41\ldots.
  • Go the distance 11 from town 11 to town 22 at a speed of 11, taking a time of 11.
  • Go the distance 11 from town 22 to the origin at a speed of 11, taking a time of 11.
1 2
4 4
1 0
0 1
4.3713203436

Here is one optimal way to complete the trip.

  • Go the distance 11 from the origin to chest 11 at a speed of 11, taking a time of 11.
  • Go the distance 1.411.41\ldots from chest 11 to chest 22 at a speed of 22, taking a time of 0.7070.707\ldots.
  • Go the distance 55 from chest 22 to town 11 at a speed of 44, taking a time of 1.251.25.
  • Go the distance 5.655.65\ldots from town 11 to the origin at a speed of 44, taking a time of 1.411.41\ldots.