CF1584G.Eligible Segments

NOI/NOI+/CTSC

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given nn distinct points p1,p2,…,pnp_1, p_2, \ldots, p_n on the plane and a positive integer RR.

Find the number of pairs of indices (i,j)(i, j) such that 1≤i<j≤n1 \le i \lt j \le n, and for every possible kk (1≤k≤n1 \le k \le n) the distance from the point pkp_k to the segment between points pip_i and pjp_j is at most RR.

给你平面上 nn 个互不相同的点 p1,p2,…,pnp_1, p_2, \ldots, p_n 以及一个正整数 RR。

请找出满足以下条件的下标对 (i,j)(i, j) 的数量:1≤i<j≤n1 \le i \lt j \le n,且对任意 kk(1≤k≤n1 \le k \le n),点 pkp_k 到线段 pipjp_i p_j 的距离都不超过 RR。

输入格式

The first line contains two integers nn, RR (1≤n≤30001 \le n \le 3000, 1≤R≤1051 \le R \le 10^5) — the number of points and the maximum distance between a point and a segment.

Each of the next nn lines contains two integers xix_i, yiy_i (−105≤xi,yi≤105-10^5 \le x_i, y_i \le 10^5) that define the ii-th point pi=(xi,yi)p_i=(x_i, y_i). All points are distinct.

It is guaranteed that the answer does not change if the parameter RR is changed by at most 10−210^{-2}.

第一行包含两个整数 nn 和 RR(1≤n≤30001 \le n \le 3000,1≤R≤1051 \le R \le 10^5)—— 分别表示点的个数以及点到线段的最大允许距离。

接下来的 nn 行中,每行包含两个整数 xix_i、yiy_i(−105≤xi,yi≤105-10^5 \le x_i, y_i \le 10^5),用于定义第 ii 个点 pi=(xi,yi)p_i = (x_i, y_i)。所有点互不相同。

保证当参数 RR 的变化量不超过 10−210^{-2} 时,答案不会改变。

输出格式

Print the number of suitable pairs (i,j)(i, j).

输出合适的数对 (i,j)(i, j) 的个数。

输入输出样例

  • 输入#1

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

    输出#1

    1
  • 输入#2

    3 3
    1 -1
    -1 -1
    0 1

    输出#2

    3

说明/提示

In the first example, the only pair of points (−3,0)(-3, 0), (3,0)(3, 0) is suitable. The distance to the segment between these points from the points (0,1)(0, 1) and (0,−1)(0, -1) is equal to 11, which is less than R=2R=2.

In the second example, all possible pairs of points are eligible.

在第一个例子中,唯一合适的点对是 (−3,0)(-3, 0) 和 (3,0)(3, 0)。点 (0,1)(0, 1) 与 (0,−1)(0, -1) 到这两点之间线段的距离均为 11,小于 R=2R=2。

在第二个例子中,所有可能的点对均符合条件。

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

首页