CF1886B.Fear of the Dark

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Monocarp tries to get home from work. He is currently at the point O=(0,0)O = (0, 0) of a two-dimensional plane; his house is at the point P=(Px,Py)P = (P_x, P_y).

Unfortunately, it is late in the evening, so it is very dark. Monocarp is afraid of the darkness. He would like to go home along a path illuminated by something.

Thankfully, there are two lanterns, located in the points A=(Ax,Ay)A = (A_x, A_y) and B=(Bx,By)B = (B_x, B_y). You can choose any non-negative number ww and set the power of both lanterns to ww. If a lantern's power is set to ww, it illuminates a circle of radius ww centered at the lantern location (including the borders of the circle).

You have to choose the minimum non-negative value ww for the power of the lanterns in such a way that there is a path from the point OO to the point PP which is completely illuminated. You may assume that the lanterns don't interfere with Monocarp's movement.

The picture for the first two test cases

Monocarp 尝试从公司回家。他当前位于二维平面上的点 O=(0,0)O = (0, 0);他的家位于点 P=(Px,Py)P = (P_x, P_y)。

不幸的是,此时已近深夜,四周一片漆黑。Monocarp 害怕黑暗,因此希望沿着一条被光源完全照亮的路径回家。

幸运的是,存在两盏灯笼,分别位于点 A=(Ax,Ay)A = (A_x, A_y) 和 B=(Bx,By)B = (B_x, B_y)。你可以选择任意一个非负实数 ww,并将两盏灯笼的功率均设为 ww。若一盏灯笼的功率设为 ww,则它会照亮以该灯笼位置为中心、半径为 ww 的圆形区域(包含圆周边界)。

你需要确定最小的非负值 ww,使得存在一条从点 OO 到点 PP 的、全程均被照亮的路径。你可以假设灯笼不会妨碍 Monocarp 的移动。

前两个测试用例的示意图

输入格式

The first line of the input contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

Each test case consists of three lines:

  • the first line contains two integers PxP_x and PyP_y (−103≤Px,Py≤103-10^3 \le P_x, P_y \le 10^3) — the location of Monocarp's house;
  • the second line contains two integers AxA_x and AyA_y (−103≤Ax,Ay≤103-10^3 \le A_x, A_y \le 10^3) — the location of the first lantern;
  • the third line contains two integers BxB_x and ByB_y (−103≤Bx,By≤103-10^3 \le B_x, B_y \le 10^3) — the location of the second lantern.

Additional constraint on the input:

  • in each test case, the points OO, PP, AA and BB are different from each other.

输入的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4),表示测试用例的数量。

每个测试用例由三行组成:

  • 第一行包含两个整数 PxP_x 和 PyP_y(−103≤Px,Py≤103-10^3 \le P_x, P_y \le 10^3),表示 Monocarp 家的位置;
  • 第二行包含两个整数 AxA_x 和 AyA_y(−103≤Ax,Ay≤103-10^3 \le A_x, A_y \le 10^3),表示第一盏灯笼的位置;
  • 第三行包含两个整数 BxB_x 和 ByB_y(−103≤Bx,By≤103-10^3 \le B_x, B_y \le 10^3),表示第二盏灯笼的位置。

输入的附加约束:

  • 在每个测试用例中,点 OO、PP、AA 和 BB 互不相同。

输出格式

For each test case, print the answer on a separate line — one real number equal to the minimum value of ww such that there is a completely illuminated path from the point OO to the point PP.

Your answer will be considered correct if its absolute or relative error does not exceed 10−610^{-6} — formally, if your answer is aa, and the jury's answer is bb, your answer will be accepted if ∣a−b∣max⁡(1,b)≤10−6\dfrac{|a - b|}{\max(1, b)} \le 10^{-6}.

对于每个测试用例,在单独一行中输出答案——即满足存在一条从点 OO 到点 PP 的完全被照亮路径的最小 ww 值(一个实数)。

若你的答案的绝对误差或相对误差不超过 10−610^{-6},则该答案视为正确。形式化地说,若你的答案为 aa,评测机的标准答案为 bb,则当 ∣a−b∣max⁡(1,b)≤10−6\dfrac{|a - b|}{\max(1, b)} \le 10^{-6} 时,你的答案将被接受。

输入输出样例

  • 输入#1

    2
    3 3
    1 0
    -1 6
    3 3
    -1 -1
    4 3

    输出#1

    3.6055512755
    3.2015621187

输入解题思路,AI测评打分。不知道怎么写?

首页