CF1584G.Eligible Segments
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n distinct points p1,p2,…,pn on the plane and a positive integer R.
Find the number of pairs of indices (i,j) such that 1≤i<j≤n, and for every possible k (1≤k≤n) the distance from the point pk to the segment between points pi and pj is at most R.
给你平面上 n 个互不相同的点 p1,p2,…,pn 以及一个正整数 R。
请找出满足以下条件的下标对 (i,j) 的数量:1≤i<j≤n,且对任意 k(1≤k≤n),点 pk 到线段 pipj 的距离都不超过 R。
输入格式
The first line contains two integers n, R (1≤n≤3000, 1≤R≤105) — the number of points and the maximum distance between a point and a segment.
Each of the next n lines contains two integers xi, yi (−105≤xi,yi≤105) that define the i-th point pi=(xi,yi). All points are distinct.
It is guaranteed that the answer does not change if the parameter R is changed by at most 10−2.
第一行包含两个整数 n 和 R(1≤n≤3000,1≤R≤105)—— 分别表示点的个数以及点到线段的最大允许距离。
接下来的 n 行中,每行包含两个整数 xi、yi(−105≤xi,yi≤105),用于定义第 i 个点 pi=(xi,yi)。所有点互不相同。
保证当参数 R 的变化量不超过 10−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) is suitable. The distance to the segment between these points from the points (0,1) and (0,−1) is equal to 1, which is less than R=2.
In the second example, all possible pairs of points are eligible.
在第一个例子中,唯一合适的点对是 (−3,0) 和 (3,0)。点 (0,1) 与 (0,−1) 到这两点之间线段的距离均为 1,小于 R=2。
在第二个例子中,所有可能的点对均符合条件。
输入解题思路,AI测评打分。不知道怎么写?