#abc274e. E - Booster

E - Booster

Score : 500500 points

问题描述

在二维平面上,有 NN 个城镇和 MM 个宝箱。第 ii 个城镇位于坐标 (Xi,Yi)(X_i,Y_i),第 ii 个宝箱位于坐标 (Pi,Qi)(P_i,Q_i)

高桥将进行一次旅行,他从原点出发,访问所有 NN 个城镇,然后返回原点。 虽然不一定需要访问宝箱,但每个宝箱中都包含一个加速器。每次他拾取加速器时,他的移动速度都会翻倍。

高桥的初始移动速度为 11。求完成这次旅行所需的最短时间。

以上为通义千问 qwen-max 翻译,仅供参考。

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}.

Sample Input 1

2 1
1 1
0 1
1 0

Sample Output 1

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.

Sample Input 2

2 1
1 1
0 1
100 0

Sample Output 2

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.

Sample Input 3

1 2
4 4
1 0
0 1

Sample Output 3

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.

update @ 2024/3/10 11:33:01