Pea-City
Time limit2sMemory limit1024 MB
Given N points, find the minimum-area rectangle of any orientation that encloses all of them and print its four corners in counterclockwise order.
- Level
Medium6 of 10
- Topics
- Geometry, Divide and conquer
- Solved
- No attempts yet
Problem
The Pea King was a wise ruler and a good strategist. He spent all his time dealing with state affairs. As the kingdom grew, the population increased, and new houses popped up everywhere like mushrooms after the rain. The kings of neighboring states grew envious and began planning a war.
To protect the capital from the invaders, the Pea King decided to build a new city wall around the capital's borders that would enclose all the buildings on the city outskirts as well.
For the aesthetic effect, namely to make the map on the wall in the king's parlor look pretty, it was decided that the capital city should have rectangular borders. Keeping this in mind, the total land area should remain as small as possible, and all houses registered should stay inside the borders of the rectangular city.
Input
The first line contains a single integer , the number of houses in the city (). The following lines each contain a pair of integers , , the Cartesian coordinates of a house (). It is guaranteed that at least three houses are not on one line.
Output
Output the coordinates of the four corners of the rectangle in counterclockwise order, one pair of coordinates per line. The answer is considered correct if the absolute or relative error of the rectangle's area does not exceed , and all houses are strictly inside the city or at a distance of at most from its borders.