CF1446F.Line Distance

NOI/NOI+/CTSC

通过率:0%

时间限制:7.50s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an integer kk and nn distinct points with integer coordinates on the Euclidean plane, the ii-th point has coordinates (xi,yi)(x_i, y_i).

Consider a list of all the n(n−1)2\frac{n(n - 1)}{2} pairs of points ((xi,yi),(xj,yj))((x_i, y_i), (x_j, y_j)) (1≤i<j≤n1 \le i \lt j \le n). For every such pair, write out the distance from the line through these two points to the origin (0,0)(0, 0).

Your goal is to calculate the kk-th smallest number among these distances.

给你一个整数 kk 和平面上 nn 个互不相同的整数坐标点,其中第 ii 个点的坐标为 (xi,yi)(x_i, y_i)。

考虑所有 n(n−1)2\frac{n(n - 1)}{2} 个点对 ((xi,yi),(xj,yj))((x_i, y_i), (x_j, y_j))(其中 1≤i<j≤n1 \le i \lt j \le n)构成的列表。对每个这样的点对,计算过这两点的直线到原点 (0,0)(0, 0) 的距离。

你的目标是计算这些距离中第 kk 小的数。

输入格式

The first line contains two integers nn, kk (2≤n≤1052 \le n \le 10^5, 1≤k≤n(n−1)21 \le k \le \frac{n(n - 1)}{2}).

The ii-th of the next nn lines contains two integers xix_i and yiy_i (−104≤xi,yi≤104-10^4 \le x_i, y_i \le 10^4) — the coordinates of the ii-th point. It is guaranteed that all given points are pairwise distinct.

第一行包含两个整数 nn 和 kk(2≤n≤1052 \le n \le 10^5,1≤k≤n(n−1)21 \le k \le \frac{n(n - 1)}{2})。

接下来的 nn 行中,第 ii 行包含两个整数 xix_i 和 yiy_i(−104≤xi,yi≤104-10^4 \le x_i, y_i \le 10^4),表示第 ii 个点的坐标。保证所有给定的点两两互不相同。

输出格式

You should output one number — the kk-th smallest distance from the origin. Your answer is considered correct if its 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 accepted if and only if ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}.

你应该输出一个数字——从原点出发的第 kk 小的距离。若你的答案的绝对误差或相对误差不超过 10−610^{-6},则视为正确。

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

输入输出样例

  • 输入#1

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

    输出#1

    0.707106780737

说明/提示

There are 66 pairs of points:

  • Line 1−21-2 : distance 00 from the origin
  • Line 1−31-3 : distance 22≈0.707106781\frac{\sqrt{2}}{2} \approx 0.707106781 from the origin
  • Line 1−41-4 : distance 22 from the origin
  • Line 2−32-3 : distance 11 from the origin
  • Line 2−42-4 : distance 22 from the origin
  • Line 3−43-4 : distance 229≈0.371390676\frac{2}{\sqrt{29}} \approx 0.371390676 from the origin

The third smallest distance among those is approximately 0.7071067810.707106781.

共有 66 对点:

  • 直线 11-22:到原点的距离为 00
  • 直线 11-33:到原点的距离为 22≈0.707106781\frac{\sqrt{2}}{2} \approx 0.707106781
  • 直线 11-44:到原点的距离为 22
  • 直线 22-33:到原点的距离为 11
  • 直线 22-44:到原点的距离为 22
  • 直线 33-44:到原点的距离为 229≈0.371390676\frac{2}{\sqrt{29}} \approx 0.371390676

其中第三小的距离约为 0.7071067810.707106781。

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

首页