CF1584G.Eligible Segments

普及/提高-

通过率:0%

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 1i<jn1 \le i < j \le n , and for every possible kk ( 1kn1 \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 .

输入格式

The first line contains two integers nn , RR ( 1n30001 \le n \le 3000 , 1R1051 \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 ( 105xi,yi105-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 10210^{-2} .

输出格式

Print the number of suitable pairs (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.

首页