Bitcoin Mining Fields
Time limit1sMemory limit64 MB
Given up to a million integer points, find the largest squared Euclidean distance between any two of them and print it.
Problem
Bitcoin mining uses a lot of power. One day Ali and Betty decided to start their own mining fields in the center of Cheras, one field each. They went to Siva, the mayor of Cheras, to ask for locations.
Siva showed them a grid map with every possible location for a mining field. Mining draws a large amount of power, so Siva wants the two fields as far apart as possible to keep power spikes out of the neighbourhood.
Given the coordinates of all possible mining sites, find the largest Euclidean (straight line) distance between two of them. A site coordinate is always an integer.
Floating point arithmetic is easy to get slightly wrong, so you only have to output the square of that largest distance. The square of the Euclidean distance between two points and is defined as
Input
The first line has the number of possible mining sites ().
The second line has (), the largest absolute value a coordinate can take, so every site satisfies and .
Each of the next lines has two integers and , the coordinates of one possible mining site. The same coordinate can appear more than once.
Output
Print the square of the Euclidean distance between the two farthest possible mining sites, as a single integer.