Largest Square
Time limit10sMemory limit256 MB
Given N points on a plane, find the area of the largest square with all four vertices among the points, or 0 when no square exists.
- Level
Medium6 of 10
- Topics
- Geometry, Hash map, Brute force
- Solved
- No attempts yet
Problem
Given points on a plane, find the area of the largest square whose four vertices are all among the given points. The sides of the square need not be parallel to the coordinate axes; tilted squares are also allowed.
Input
The first line contains the number of test cases .
For each test case, the first line contains the number of points (). Each of the next lines contains the and coordinates of a point, separated by a space. All coordinates are integers between and inclusive, and no two points share the same position.
Output
For each test case, print the area of the largest square that can be formed, one per line. If no square can be formed, print .