#C5953. Closest Pair Problem on a 2D Plane

    ID: 49659 Type: Default 1000ms 256MiB

Closest Pair Problem on a 2D Plane

Closest Pair Problem on a 2D Plane

You are given a set of points on a 2D plane. Your task is to find the minimum Euclidean distance between any two distinct points. The Euclidean distance between two points \( (x_1, y_1) \) and \( (x_2, y_2) \) is given by:

$$\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}$$

If there is less than two points, output inf (infinity).

inputFormat

The first line contains an integer (n) (number of points). Each of the following (n) lines contains two space-separated integers representing the x and y coordinates of a point.

outputFormat

Output a single line containing the minimum Euclidean distance between any two points rounded to 6 decimal places. If there is only one point, output "inf".## sample

4
0 0
1 1
4 5
13 14
1.414214