#C11763. Closest Pair of Points

    ID: 41115 Type: Default 1000ms 256MiB

Closest Pair of Points

Closest Pair of Points

Given a set of points in a 2-dimensional plane, the task is to determine the smallest Euclidean distance between any pair of distinct points. The Euclidean distance between two points ((x_1, y_1)) and ((x_2, y_2)) is defined as

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

The input consists of multiple test cases. For each test case, the first line contains an integer (n) (with (n \ge 2)) representing the number of points. Each of the following (n) lines contains two space-separated integers which denote the (x) and (y) coordinates of a point. Your solution should compute the smallest distance among all pairs of points and output the result formatted to four decimal places.

inputFormat

The input is provided via standard input (stdin) and contains one or more test cases. Each test case is formatted as follows:

  • The first line contains an integer \(n\) (\(n \ge 2\)), indicating the number of points.
  • The next \(n\) lines each contain two space-separated integers representing the \(x\) and \(y\) coordinates of a point.

outputFormat

For each test case, output a single line containing the smallest Euclidean distance between any two points, formatted to four decimal places. The output should be written to standard output (stdout).

## sample
4
0 0
0 2
2 0
2 2
2.0000

</p>