CF1059D.Nature Reserve

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There is a forest that we model as a plane and live nn rare animals. Animal number ii has its lair in the point (xi,yi)(x_{i}, y_{i}). In order to protect them, a decision to build a nature reserve has been made.

The reserve must have a form of a circle containing all lairs. There is also a straight river flowing through the forest. All animals drink from this river, therefore it must have at least one common point with the reserve. On the other hand, ships constantly sail along the river, so the reserve must not have more than one common point with the river.

For convenience, scientists have made a transformation of coordinates so that the river is defined by y=0y = 0. Check whether it is possible to build a reserve, and if possible, find the minimum possible radius of such a reserve.

有一片森林,我们将其建模为一个平面,其中有 nn 只珍稀动物。第 ii 只动物的巢穴位于点 (xi,yi)(x_{i}, y_{i})。为了保护它们,决定建立一个自然保护区。

该保护区必须是一个包含所有巢穴的圆形区域。森林中还有一条笔直的河流穿过。所有动物都从这条河流饮水,因此保护区与河流至少需有一个公共点;但另一方面,船只持续在河上航行,因此保护区与河流的公共点不得超过一个。

为方便起见,科学家已对坐标系进行变换,使得河流由直线 y=0y = 0 表示。请判断是否可能建造这样的保护区;若可能,求出满足条件的最小可能半径。

输入格式

The first line contains one integer nn (1≤n≤1051 \le n \le 10^5) — the number of animals.

Each of the next nn lines contains two integers xix_{i}, yiy_{i} (−107≤xi,yi≤107-10^7 \le x_{i}, y_{i} \le 10^7) — the coordinates of the ii-th animal's lair. It is guaranteed that yi≠0y_{i} \neq 0. No two lairs coincide.

第一行包含一个整数 nn(1≤n≤1051 \le n \le 10^5)——动物的数量。

接下来的 nn 行中,每行包含两个整数 xix_{i}、yiy_{i}(−107≤xi,yi≤107-10^7 \le x_{i}, y_{i} \le 10^7)——第 ii 只动物巢穴的坐标。保证 yi≠0y_{i} \neq 0。任意两个巢穴的坐标均不相同。

输出格式

If the reserve cannot be built, print −1-1. Otherwise print the minimum radius. Your answer will be accepted if absolute or relative error does not exceed 10−610^{-6}.

Formally, let your answer be aa, and the jury's answer be bb. Your answer is considered correct if ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}.

如果无法建造水库,则输出 −1-1;否则输出最小半径。只要你的答案的绝对误差或相对误差不超过 10−610^{-6},即视为正确。

形式化地,设你的答案为 aa,评测组的答案为 bb。当且仅当 ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6} 时,你的答案被视为正确。

输入输出样例

  • 输入#1

    1
    0 1

    输出#1

    0.5
  • 输入#2

    3
    0 1
    0 2
    0 -3

    输出#2

    -1
  • 输入#3

    2
    0 1
    1 1

    输出#3

    0.625

说明/提示

In the first sample it is optimal to build the reserve with the radius equal to 0.50.5 and the center in (0, 0.5)(0,\ 0.5).

In the second sample it is impossible to build a reserve.

In the third sample it is optimal to build the reserve with the radius equal to 58\frac{5}{8} and the center in (12, 58)(\frac{1}{2},\ \frac{5}{8}).

在第一个样例中,最优方案是建造一个半径为 0.50.5、中心位于 (0, 0.5)(0,\ 0.5) 的保护区。

在第二个样例中,无法建造保护区。

在第三个样例中,最优方案是建造一个半径为 58\frac{5}{8}、中心位于 (12, 58)(\frac{1}{2},\ \frac{5}{8}) 的保护区。

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

首页