Cookies
Time limit2sMemory limit1024 MB
Split a given convex quadrilateral into exactly three trapezoids with nonzero area that do not overlap and together cover the whole quadrilateral.
- Level
Medium6 of 10
- Topics
- Geometry, Implementation
- Solved
- No attempts yet
Statement
Young Luke is a very gifted Jedi. Besides his remarkable talent for getting into trouble, he can move objects without touching them. Unfortunately, telekinesis lessons start only in the fifth grade of the Jedi school, so he found an old book in his father's library called Telekinesis for the Little Ones.
The first exercise in the book was moving a cookie through space by thought. Luke had a whole pack of square cookies at hand, so he decided to test his abilities. According to the book, to move a square cookie with telekinesis, you must first break it into exactly three trapezoid pieces, then concentrate and use the force.
Help Luke break the cookie so that exactly three pieces are formed, each of which has the shape of a trapezoid (a convex quadrilateral with two parallel sides).
Input
The input file contains the cookie, a quadrilateral. Four lines give the coordinates of its vertices in counterclockwise order. The i-th line contains two numbers x_i and y_i, the coordinates of the i-th vertex.
No three points lie on the same line.
All coordinates have absolute value at most .
Output
Print three quadrilaterals to the output file. Each one is a trapezoid described by four lines, and each line contains two real numbers x_i and y_i, the coordinates of the i-th vertex of the trapezoid, in counterclockwise order. Each trapezoid must have nonzero area. Print an empty line after each trapezoid description.
All points of each trapezoid must lie inside or on the boundary of the original quadrilateral. The trapezoids must not overlap with nonzero area, and every point of the original quadrilateral must be covered by at least one of the three trapezoids.
If several solutions exist, print any of them. When the answer is checked, two areas are considered equal if their relative or absolute difference is at most , a point lies on a line if its distance to the line is at most , and two lines are parallel if the sine of the angle between them is at most .
Hint
Note that the resulting trapezoids may have both pairs of opposite sides parallel to each other. This case is covered by the first example.
The second example is shown in the following figure.
