#B4253. Planar Geometry: Maximum Distance Calculation
Planar Geometry: Maximum Distance Calculation
Planar Geometry: Maximum Distance Calculation
Little Keke is learning plane geometry! Given n points on the plane \( (x_1,y_1), (x_2,y_2), \ldots, (x_n,y_n) \), the task is to compute one of the following two values based on an input parameter:
- Euclidean Distance Squared: Compute the maximum squared Euclidean distance between any pair of points. The Euclidean distance between two points \( (x_i,y_i) \) and \( (x_j,y_j) \) is defined as \(\sqrt{(x_i-x_j)^2+(y_i-y_j)^2}\), so the squared distance is \((x_i-x_j)^2+(y_i-y_j)^2\).
- Manhattan Distance: Compute the maximum Manhattan distance between any pair of points. The Manhattan distance is defined as \(|x_i-x_j|+|y_i-y_j|\).
The input includes an operation type to determine which distance to calculate:
- If
op = 1
, output the maximum squared Euclidean distance. - If
op = 2
, output the maximum Manhattan distance.
inputFormat
The first line contains two integers n
and op
(op
is either 1 or 2), where n
is the number of points.
Each of the following n
lines contains two space-separated integers xi
and yi
representing the coordinates of the i-th point.
Note: If op = 1
, you need to output the maximum squared Euclidean distance; if op = 2
, you need to output the maximum Manhattan distance.
outputFormat
Output a single integer representing the maximum distance value as described above.
sample
2 1
0 0
3 4
25