#P1959. Largest Temple Square
Largest Temple Square
Largest Temple Square
Long ago, there was a temple whose top‐view was exactly a square, built by 4 cylindrical pillars placed at its corners. Over time, the pillars collapsed leaving only circular traces on the ground. Today, many such traces exist, but experts believe that one set belongs to the largest temple.
Your task is to write a program that, given the coordinates of the cylindrical traces, finds the square formed by 4 points having the maximum possible area. This square represents the temple. Note that the sides of the square do not have to be parallel to the coordinate axes.
More formally, given a set of points, choose 4 distinct points such that they can be the vertices of a square. For a square with side length s, its area is given by \[ A = s^2 \] If a valid square cannot be found, output 0.
Example: Consider 10 points. Among them, the points (4,2), (5,2), (5,3), (4,3) form a square with area 1, while the points (1,1), (4,0), (5,3), (2,4) form a square with area 10. The latter is the largest temple square, so the correct answer is 10.
inputFormat
The first line of input contains an integer N representing the number of cylindrical trace points. Each of the next N lines contains two space‐separated integers x and y, representing the coordinates of a trace.
outputFormat
Output a single integer — the maximum area of a square that can be formed by any 4 of the given points. If no square exists, output 0.
sample
10
1 1
4 0
5 3
2 4
4 2
5 2
5 3
4 3
0 0
10 10
10