Geometry Enjoyer
Time limit7sMemory limit2048 MB
Given the pairwise intersection points of the extended sides of a convex polygon with no parallel sides, recover the polygon's vertices as exact rational coordinates.
- Level
Hard9 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
Altair was playing with the points on the plane, as usual. One day he found a new game and asked you to play it with him.
He drew a convex polygon with sides on the plane. No two sides of the polygon are parallel. Then he extended every side to a line and found the intersection point of every pair of lines.
He now gives you the points he got. Find the original polygon from these points.
Input
The first line contains one integer (), the number of points.
Each of the next lines contains four integers , , , and (, ). The X coordinate of the -th point is , and the Y coordinate is . and are coprime, and and are coprime.
It is guaranteed that the polygon is uniquely determined by the given points.
Output
Print the number of vertices on the first line.
Each of the next lines contains the coordinates of one vertex in the form , , , . The vertices may be printed in any order. Each and must be coprime, and each and must be coprime.