Smallest Square 1
Time limit2sMemory limit512 MB
Given N points, find the smallest axis-aligned square with integer vertices that strictly contains at least N-2 of the points, and output its area.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Brute force, Binary search
- Solved
- No attempts yet
Problem
There are points on the coordinate plane. Find the square of smallest area that satisfies all three conditions below.
- All four vertices of the square have integer coordinates.
- All four sides of the square are parallel to the coordinate axes.
- At least of the given points lie strictly inside the square. A point on the boundary does not count as being inside.
Write a program that prints the smallest area of such a square.
Input
The first line contains the number of points . ()
Each of the next lines contains the coordinates and of one point, separated by a space. ()
No point is given more than once.
Output
Print the area of the smallest square that satisfies the conditions.