#P16393. [ECUSTPC 2026 Spring] 聚光灯下

    ID: 18407 远端评测题 5000ms 1024MiB 尝试: 0 已通过: 0 显示难度提高 上传者: 标签>计算几何二分三分Special Judge凸包2026高校校赛极角排序

[ECUSTPC 2026 Spring] 聚光灯下

Background

:::epigraph As the crimson curtain is slowly lifted, you have no way back. Even if the audience is a sky full of gods and Buddhas, or unspeakable disasters... as long as you are still on the stage, this play must go on until the curtain falls. :::

The attachments provide an English PDF version of all problems in this contest, which you may print out for reading.

Problem Description

The stage arranged by Bean is about to begin a wonderful performance...

The stage is a two-dimensional Euclidean plane. Character A initially stands at the center of the stage, i.e., the origin (0,0)(0, 0). Above the stage there are nn spotlights. Each spotlight illuminates a circular region on the plane with center (xi,yi)(x_i, y_i) and radius xi2+yi2\sqrt{x_i^2 + y_i^2}. The circular boundary is also included in the illuminated region. It can be observed that the stage center lies inside the illuminated region of every spotlight.

To make the performance more dramatic, A wants to stay within the illuminated region of every spotlight throughout her movement, and reach the point that is farthest from the stage center.

Help A find the maximum possible distance from the stage center that she can reach, under the condition that her path never leaves the illuminated region of any spotlight.

Input Format

The first line contains an integer T (1≤T≤105)T \ (1 \le T \le 10^5), the number of testdata.

For each test case, the first line contains an integer n (1≤n≤105)n \ (1 \le n \le 10^5), the number of spotlights.

The next nn lines each contain two integers xix_i and yi (−105≤xi,yi≤105, (xi,yi)y_i \ (-10^5 \le x_i, y_i \le 10^5, \ (x_i, y_i) is not the origin), representing the center of a spotlight’s illuminated region.

It is guaranteed that ∑n≤3×105\sum n \le 3 \times 10^5 over all test cases.

Within a single test case, it is guaranteed that the centers of any two spotlights are different, and no three spotlight centers are collinear.

Output Format

For each test case, output one real number dd on a single line, representing the maximum distance from the stage center that A can reach under the conditions described.

Your answer dd will be accepted if the absolute error or relative error between dd and the standard answer ansans is less than 10−610^{-6}.

Formally, your answer dd will be accepted if ∣d−ans∣max⁡(1,ans)<10−6\frac{|d - ans|}{\max(1, ans)} < 10^{-6}.

Please control the total precision of your output. Do not output an excessively large file. It is recommended to print no more than 15 digits after the decimal point.

2
2
0 1
1 0
4
1 0
0 1
-1 0
0 -1
1.414213562
0.000000000

Hint

Explanation for Sample 1

:::align{center} :::

The figure above shows the illuminated regions of the spotlights in the first test case. You can see that the farthest point A can reach is (1,1)(1, 1), so the answer is d=2d = \sqrt{2}.

In the second test case, the illuminated regions have no common intersection other than the origin, so the farthest point A can reach is the origin (0,0)(0, 0), and the answer is 00.

Translated by ChatGPT 5