P21112 [CodeChef] PHCUL
提高-
题目描述

Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef decided to exercise by running somewhere from ShareChat. He chose three sets of points in a plane:
A set of $N$ points (numbered $1$ through $N$): for each valid $i$, the $i$-th of them has coordinates $(a_{i}, b_{i})$.
A set of $M$ points (numbered $1$ through $M$): for each valid $i$, the $i$-th of them has coordinates $(c_{i}, d_{i})$.
A set of $K$ points (numbered $1$ through $K$): for each valid $i$, the $i$-th of them has coordinates $(e_{i}, f_{i})$.

ShareChat has coordinates $(x, y)$. Chef must choose one point $(a_{j}, b_{j})$, one point $(c_{k}, d_{k})$, and one point $(e_{l}, f_{l})$. Then, he starts running from ShareChat, visits the chosen points $(a_{j}, b_{j})$ and $(c_{k}, d_{k})$ in any order, and then runs to the point $(e_{l}, f_{l})$, where he finishes his run.

Help Chef find the minimum distance he has to run.

------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains two space-separated integers $x$ and $y$.
The second line contains three space-separated integers $N$, $M$ and $K$.
The third line contains $2N$ space-separated integers $a_{1}, b_{1}, a_{2}, b_{2}, \ldots, a_{N}, b_{N}$.
The fourth line contains $2M$ space-separated integers $c_{1}, d_{1}, c_{2}, d_{2}, \ldots, c_{M}, d_{M}$.
The fifth line contains $2K$ space-separated integers $e_{1}, f_{1}, e_{2}, f_{2}, \ldots, e_{K}, f_{K}$.

------ Output ------
For each test case, print a single line containing one real number ― the minimum distance.

Your answer will be considered correct if its absolute or relative error does not exceed $10^{-6}$.

------ Constraints ------
$1 ≤ T ≤ 5,000$
$1 ≤ N, M, K ≤ 5,000$
$0 ≤ x, y ≤ 10^{9}$
$0 ≤ a_{i}, b_{i} ≤ 10^{9}$ for each valid $i$
$0 ≤ c_{i}, d_{i} ≤ 10^{9}$ for each valid $i$
$0 ≤ e_{i}, f_{i} ≤ 10^{9}$ for each valid $i$
the sum of $N+M+K$ over all test cases does not exceed $15,000$

------ Subtasks ------
Subtask #1 (50 points): $1 ≤ N, M, K ≤ 100$

Subtask #2 (50 points): original constraints

----- Sample Input 1 ------
2
1 4
3 2 2
4 4 2 0 8 1
10 1 3 1
1 3 9 5
6 4
2 2 3
7 10 5 7
1 6 2 3
1 8 0 7 0 2
----- Sample Output 1 ------
8.1820424980
8.6995968482
----- explanation 1 ------
Example case 1:

  • The black point is ShareChat,
  • Points from the first set are red.
  • Points from the second set are green.
  • Points from the third set are blue.
  • The black line corresponds to Chef's run.

Chef should run from $(1, 4)$ to $(3, 1)$, then to $(2, 0)$ and then to $(1, 3)$. The distance is $\sqrt{13}+\sqrt{2}+\sqrt{10} \doteq 8.1820424980$.

Example case 2:

Chef should run from $(6, 4)$ to $(5, 7)$, then to $(1, 6)$ and then to $(0, 7)$. The distance is $\sqrt{10}+\sqrt{17}+\sqrt{2} \doteq 8.6995968482$.

输入格式

见题面

输出格式

见题面

样例输入
2 1 4 3 2 2 4 4 2 0 8 1 10 1 3 1 1 3 9 5 6 4 2 2 3 7 10 5 7 1 6 2 3 1 8 0 7 0 2
样例输出
8.1820424980 8.6995968482