Editorial for COCI '14 Contest 1 #2 Klopka


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Iterating once over given points (or during the input) we find the leftmost point (the one with the minimal x-coordinate), the rightmost point (the one with the maximal x-coordinate), the lowermost point (the one with the minimal y-coordinate) and the topmost point (the one with the maximal y-coordinate). We do this using the standard algorithm of finding minimum/maximum: remember the minimum/maximum so far, compare it to the new value and change it if needed.

The four vertices found make a rectangle, but we need a square. In order for the square to cover all points, its side has to be equal to the longer side of the mentioned rectangle. When we've found the side length of the square, we need to square the value (multiply it by itself) to get the required area.


Comments

There are no comments at the moment.