#K54292. Minimum Cost to Build Railway
Minimum Cost to Build Railway
Minimum Cost to Build Railway
You are given two sets of points representing stations in Town A and Town B respectively. Your task is to determine the minimum Euclidean distance between any station in Town A and any station in Town B. The computed distance must be rounded to six decimal places.
Let the coordinates of a station in Town A be \((x_1,y_1)\) and that in Town B be \((x_2,y_2)\). The Euclidean distance is given by the formula: \[ D = \sqrt{(x_1-x_2)^2 + (y_1-y_2)^2} \]
Input will be provided via standard input (stdin) and output should be written to standard output (stdout).
inputFormat
The first line contains two integers n
and m
— the number of stations in Town A and Town B respectively.
The next n
lines each contain two integers representing the coordinates of a station in Town A.
This is followed by m
lines each containing two integers representing the coordinates of a station in Town B.
You may assume that all coordinates are integers and are given in a single test case.
outputFormat
Output a single line containing the minimum Euclidean distance between any station in Town A and any station in Town B. The result should be rounded to six decimal places.
## sample3 2
1 1
2 2
3 3
4 4
5 5
1.414214