L - Urban Planning Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 6

注意

この問題に対する言及は、2021/4/24 18:00 JST まで禁止されています。言及がなされた場合、賠償が請求される可能性があります。 試験後に総合得点や認定級を公表するのは構いませんが、どの問題が解けたかなどの情報は発信しないようにお願いします。

問題文

ある都市には、タワー 1 からタワー N までの N 個のタワーと、環状交差点 1 から 環状交差点 M までの M 個の環状交差点があります。
この都市は半径 10^9 メートルの円の形をしています。この円の中心にあたる地点から東に x メートル、北に y メートル進んだ地点を地点 (x, y) と表すことにします。
タワー i は地点 (\mathrm{PX}_i, \mathrm{PY}_i) に建っています。
環状交差点 i は地点 (\mathrm{CX}_i, \mathrm{CY}_i) を中心とする半径 R_i メートルの円 (内部は含まない) の形をしています。
高橋君は、以下の条件を満たすようにこの都市に線分状の道路をいくつか追加します。

  • 追加される道路の端点は全て、N 個のタワーの建っている地点のうちいずれかに一致するか、M 個の環状交差点のいずれかの上に乗っている
  • 以下のルールに従って、どの 2 つのタワーが建っている地点も互いに行き来可能である
    • 今いる地点が、ある環状交差点の上にあるとき、その環状交差点上の任意の地点に移動できる
    • 今いる地点が、ある道路の端点であるとき、その道路の他方の端点に移動できる (移動は端点から端点に限ることに注意せよ)
    • これ以外の移動は許されない

追加される道路の長さの合計として考えられる最小値を求めてください。

制約

  • 2 \le N \le 50
  • 1 \le M \le 8
  • 0 \le \mathrm{PX}_i \le 1000
  • 0 \le \mathrm{PY}_i \le 1000
  • i \neq j ならば (\mathrm{PX}_i, \mathrm{PY}_i) \neq (\mathrm{PX}_j, \mathrm{PY}_j)
  • 0 \le \mathrm{CX}_i \le 1000
  • 0 \le \mathrm{CY}_i \le 1000
  • 1 \le R_i \le 1000
  • i \neq j ならば (\mathrm{CX}_i, \mathrm{CY}_i, R_i) \neq (\mathrm{CX}_j, \mathrm{CY}_j, R_j)
  • 入力に含まれる値は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N M
\mathrm{PX}_1 \mathrm{PY}_1
\mathrm{PX}_2 \mathrm{PY}_2
\mathrm{PX}_3 \mathrm{PY}_3
\hspace{22pt} \vdots
\mathrm{PX}_N \mathrm{PY}_N
\mathrm{CX}_1 \mathrm{CY}_1 R_1
\mathrm{CX}_2 \mathrm{CY}_2 R_2
\mathrm{CX}_3 \mathrm{CY}_3 R_3
\hspace{33pt} \vdots
\mathrm{CX}_M \mathrm{CY}_M R_M

出力

答えを出力せよ。
想定解答との絶対誤差または相対誤差が 10^{-5} 以下であるとき正解と判定される。


入力例 1

2 1
0 0
6 0
3 0 2

出力例 1

2.00000000000

各タワーと環状交差点の配置は下図のようになっています。

例えば以下の 2 つの道路を追加すると条件を満たします。

  • (0, 0)(1, 0) を結ぶ線分状の道路
  • (5, 0)(6, 0) を結ぶ線分状の道路

このとき、追加された道路の長さの和は 2 であり、これが最小です。


入力例 2

2 2
4 2
0 1
0 0 2
0 1 4

出力例 2

2.12310562562

各タワーと環状交差点の配置は下図のようになっています。

以下の 3 つの道路を追加するのが最適な追加方法です。

  • (0, 1)(0, 2) を結ぶ線分状の道路
  • (0, -2)(0, -3) を結ぶ線分状の道路
  • (\frac{16 \sqrt{17}}{17}, 1 + \frac{4 \sqrt{17}}{17})(4, 2) を結ぶ線分状の道路

入力例 3

3 4
9 2
5 20
0 21
0 0 2
0 0 10
16 0 10
10 15 3

出力例 3

13.10603728957

各タワーと環状交差点の配置は下図のようになっています。

Score : 6 points

Warning

Do not make any mention of this problem until April 24, 2021, 6:00 p.m. JST. In case of violation, compensation may be demanded. After the examination, you can reveal your total score and grade to others, but nothing more (for example, which problems you solved).

Problem Statement

In some city, there are N towers called Tower 1 through Tower N and M traffic circles called Traffic Circle 1 through Traffic Circle M.
The town has the shape of a circle with a radius of 10^9 meters. Let (x, y) represent the point that is x meters east and y meters north of the center of the circle.
Tower i is at (\mathrm{PX}_i, \mathrm{PY}_i).
Traffic Circle i has the shape of a circle with a radius of R_i meters centered at (\mathrm{CX}_i, \mathrm{CY}_i) (not including the interior).
In this city, Takahashi will build some number of roads, each in the shape of a line segment, to satisfy the following conditions:

  • Each endpoint of every road is a point at which one of the N towers stands or on one of the M traffic circles.
  • It is possible to travel between every pair of towers in the following manner:
    • if you are now on some traffic circle, you can get to anywhere on that traffic circle;
    • if you are now at an endpoint of some road, you can get to the other endpoint of that road (but not to intermediate points);
    • no other type of movement is allowed.

Find the minimum possible total length of the roads built.

Constraints

  • 2 \le N \le 50
  • 1 \le M \le 8
  • 0 \le \mathrm{PX}_i \le 1000
  • 0 \le \mathrm{PY}_i \le 1000
  • (\mathrm{PX}_i, \mathrm{PY}_i) \neq (\mathrm{PX}_j, \mathrm{PY}_j) for i \neq j
  • 0 \le \mathrm{CX}_i \le 1000
  • 0 \le \mathrm{CY}_i \le 1000
  • 1 \le R_i \le 1000
  • (\mathrm{CX}_i, \mathrm{CY}_i, R_i) \neq (\mathrm{CX}_j, \mathrm{CY}_j, R_j) for i \neq j
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
\mathrm{PX}_1 \mathrm{PY}_1
\mathrm{PX}_2 \mathrm{PY}_2
\mathrm{PX}_3 \mathrm{PY}_3
\hspace{22pt} \vdots
\mathrm{PX}_N \mathrm{PY}_N
\mathrm{CX}_1 \mathrm{CY}_1 R_1
\mathrm{CX}_2 \mathrm{CY}_2 R_2
\mathrm{CX}_3 \mathrm{CY}_3 R_3
\hspace{33pt} \vdots
\mathrm{CX}_M \mathrm{CY}_M R_M

Output

Print the answer. Your output is considered correct when its absolute or relative error from our answer is at most 10^{-5}.


Sample Input 1

2 1
0 0
6 0
3 0 2

Sample Output 1

2.00000000000

The towers and traffic circles are in the following positions:

We can satisfy the conditions by, for example, building the following two roads:

  • a road in the shape of a line segment connecting (0, 0) and (1, 0);
  • a road in the shape of a line segment connecting (5, 0) and (6, 0).

Here, the total length of the roads built is 2, which is the minimum possible sum.


Sample Input 2

2 2
4 2
0 1
0 0 2
0 1 4

Sample Output 2

2.12310562562

The towers and traffic circles are in the following positions:

It is optimal to build the following three roads:

  • a road connecting (0, 1) and (0, 2);
  • a road connecting (0, -2) and (0, -3);
  • a road connecting (\frac{16 \sqrt{17}}{17}, 1 + \frac{4 \sqrt{17}}{17}) and (4, 2).

Sample Input 3

3 4
9 2
5 20
0 21
0 0 2
0 0 10
16 0 10
10 15 3

Sample Output 3

13.10603728957

The towers and traffic circles are in the following positions: