#K57382. Elf Communication Groups

    ID: 30408 Type: Default 1000ms 256MiB

Elf Communication Groups

Elf Communication Groups

In this problem, you are given \( n \) elves, each located at coordinates \( (x_i, y_i) \) on a 2D plane, and a communication range \( k \). Two elves can directly communicate if the Euclidean distance between them is at most \( k \). Communication is transitive: if elf A can communicate with elf B, and elf B with elf C, then elf A can indirectly communicate with elf C.

Your task is to compute the number of connected groups of elves. The Euclidean distance \( d \) between two points \( (x_1,y_1) \) and \( (x_2,y_2) \) is defined as \( d = \sqrt{(x_1-x_2)^2 + (y_1-y_2)^2} \).

inputFormat

The input is read from standard input and has the following format:

  • The first line contains two integers \( n \) and \( k \) (where \( n \) is the number of elves and \( k \) is the communication range).
  • The next \( n \) lines each contain two integers \( x \) and \( y \), representing the coordinates of an elf.

outputFormat

Output a single integer indicating the number of distinct groups of elves that can communicate, either directly or indirectly, via the given range.

## sample
3 5
1 2
4 6
7 8
1