printРабочее место участника

printЗадачи

796. Space

Ограничения: время – 15s/20s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

During a programming contest, teams can’t sit close to each other, because then a team might copy the solution of another team. You are given the locations of the teams and the minimum required Euclidian distance between two teams. You have to find the number of pairs of teams that sit too close to each other.
Input
On the first line an integer `t` (`1\ ≤\ t\ ≤\ 100`): the number of test cases. Then for each test case:
  • One line with two integers `n` (`1\ ≤\ n\ ≤\ 100\ 000`) and `d` (`1\ ≤\ d\ ≤\ 50`): the number of teams and the minimum distance between two teams.
  • `n` lines with two integers `x_i` (`0\ ≤\ x_i\ ≤\ 1\ 000\ 000\ 000`) and `y_i` (`0\ ≤\ y_i\ ≤\ 1\ 000\ 000\ 000`): the coordinates of the `i`-th team. No two teams will have the same coordinates.
Output
For each test case:
  • One line with the number of pairs of teams that sit too close to each other.
Notes
The Euclidean distance between points `(x_1,\ y_1)` and `(x_2,\ y_2)` is `sqrt((x_1\ -\ x_2)^2\ +\ (y_1\ -\ y_2)^2)`.

Sample input

1
6 3
0 0
0 3
2 1
2 3
3 0
3 1

Sample output

8
Source: BAPC preliminary contest, 2007
loading