F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Rectangle Outline

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 54    Accepted Submission(s): 10


Problem Description
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.
 

Input
The first line contain a integer $T$(no more than 10), the following is $T$ test case, for each test case:

The first line of each test case contains a integers n (1 $\le$ n $\le$ 100,000), number of rectangular obstacles.

Each of the next n lines contains 4 integers x1, y1, x2, y2 (1 $\le$ x1 < x2 $\le$ 1,000,000,000, 1 $\le$ y1 < y2 $\le$ 1,000,000,000) specify a rectangular obstacles.

It is guaranteed that the sum of all n does not exceed 700,000.
 

Output
Output the answer as described previously.
 

Sample Input
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
 

Sample Output
8 1 1 1 3 2 3 2 4 4 4 4 2 3 2 3 1 Oops! Oops!
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 07:51:20, Gzip enabled