#P6415. Minimum Enclosing Axis-Aligned Square
Minimum Enclosing Axis-Aligned Square
Minimum Enclosing Axis-Aligned Square
You are given n points on the plane with Cartesian coordinates. Your task is to find the minimum area of a square that can enclose all the points, such that each point lies either inside or on the boundary of the square. The sides of the square must be parallel to the coordinate axes.
Note: Since the square's sides are parallel to the axes, the side length L will be determined by: $$ L = \max(x_{max} - x_{min},\; y_{max} - y_{min}) $$, and hence the area is $$ L^2 $$.
inputFormat
The first line contains an integer n (1 ≤ n ≤ 105), representing the number of points. Each of the next n lines contains two space-separated integers x and y (|x|, |y| ≤ 109), which are the coordinates of the point.
outputFormat
Output a single integer, which is the minimum area of a square that can enclose all the given points.
sample
4
0 0
1 2
2 1
3 3
9