AtCoder Beginner Contest 234
Ex
Enumerate Pairs
AtCoder
⌀ 2505
原题
←G →
翻译中…

Problem Statement

翻译中…

Given are $N$ pairs of integers $(x_i,y_i)$, numbered $1$ to $N$, and an integer $K$. List all pairs of integers $(p,q)$ that satisfy the conditions below, in the format specified in Output.

翻译中…
  • $1 \le p < q \le N$
  • $\sqrt{(x_p-x_q)^2+(y_p-y_q)^2} \le K$
翻译中…

Here, it is guaranteed that there are at most $4 \times 10^5$ such pairs of integers.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $1 \le N \le 2 \times 10^5$
  • $1 \le K \le 1.5 \times 10^9$
  • $0 \le x_i,y_i \le 10^9$
  • There are at most $4 \times 10^5$ pairs of integers that should be listed.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
x_1 y_1
x_2 y_2
\vdots
x_N y_N

翻译中…

Output

翻译中…

Print the answer in the following format.

翻译中…

M
p_1 q_1
p_2 q_2
\vdots
p_M q_M

翻译中…

The first line should contain an integer $M$, representing the number of pairs of integers to be listed. The subsequent $M$ lines should contain the pairs of integers to be listed $(p_i,q_i)$ in lexicographical order, each in its own line, separated by a space. Here, a pair of integers $(a,b)$ comes before a pair of integers $(c,d)$ if and only if one of the following conditions is satisfied.

翻译中…
  • $a<c$.
  • $a=c$ and $b<d$.
翻译中…

样例

Input #1
6 5
2 0
2 2
3 4
0 0
5 5
8 3
Output #1
9
1 2
1 3
1 4
2 3
2 4
2 5
3 4
3 5
5 6
There are $9$ pairs of integers that satisfy the conditions, which should be printed in the specified format. $(1,2),(1,3),(1,4),(2,3),(2,4),(2,5),(3,4),(3,5),(5,6)$
Input #2
2 1414213562
0 0
1000000000 1000000000
Output #2
0
There may be zero pairs of integers that satisfy the conditions.
Input #3
10 150
300 300
300 400
300 500
400 300
400 400
400 400
400 500
500 300
500 400
500 500
Output #3
29
1 2
1 4
1 5
1 6
2 3
2 4
2 5
2 6
2 7
3 5
3 6
3 7
4 5
4 6
4 8
4 9
5 6
5 7
5 8
5 9
5 10
6 7
6 8
6 9
6 10
7 9
7 10
8 9
9 10
There may be pairs of integers $(i,j)$ ($i < j$) such that $x_i=x_j$ and $y_i=y_j$.
题目信息
题号
abc234_h
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。