Problem H. Rectangle Outline
时间限制 10000 ms
内存限制 256 MB
Given a series of rectangular obstacles, one per line. Rectangular obstacles can overlap each other. Each rectangular obstacle is specified as two points on 2D plane that specify the opposite corners of a rectangle. Your job is to calculate the outline of the coverage area of all rectangular.
If the outline is made up of more than one closed polyline, print "Oops!". Otherwise, output the answer as follows: The first output point has the smallest X coordinate and then smallest Y coordinate. The second point has the same X coordinate with the first point. Then output other points in outline order. You can see more details in Sample.
It's guarantee that every rectangle's sides are parallel to OX and OY. Any point on the 2D plane will not be the vertices of two rectangles at the same time.
输入数据
输出数据
Output the answer as described previously.
样例输入
复制
3
2
1 1 3 3
2 2 4 4
4
1 2 2 5
3 2 4 5
2 1 3 3
2 4 3 6
2
1 1 2 2
3 3 4 4
样例输出
复制
8
1 1
1 3
2 3
2 4
4 4
4 2
3 2
3 1
Oops!
Oops!
$ Mathjax font initiator $