HS12MBR - Minimum Bounding Rectangle

Compute the Minimum Bounding Rectangle (MBR) that surrounds the given set of 2D objects, i.e., the axis-aligned rectangle, which contains all of the specified objects and is the one with minimum area among all rectangles with this property.

Input

First, you are given t (t<100) - the number of test cases.

Each of the test cases starts with one integer n (n < 100) - the number of objects in the set. In the successive n lines, the descriptions of the objects follow.

Each object is described by one character and some parameters:

  • a point: p x y, where x and y are point coordinates.
  • a circle: c x y r, where x and y are the center coordinates and r is the radius of the circle.
  • a line segment: l x1 y1 x2 y2, where xi, yi are the coordinates of the endpoints of the line.

Successive test cases are separated by an empty line.

Output

For each of the test cases output four numbers - the coordinates of the two points that correspond to the lower left and the upper right corner of the MBR, in the following order: first the x-coordinate of the lower left corner, then the y-coordinate of the lower left corner, the x-coordinate of the upper right corner and the y-coordinate of upper right corner.

You can assume that all object parameters are integers and that -1000 -1000 1000 1000 is a bounding rectangle for all of them.

Example

Input:
3
1
p 3 3 

2
c 10 10 20
c 20 20 10

1
l 0 0 100 20

Output:
3 3 3 3 
-10 -10 30 30
0 0 100 20

Test case description

test 1: points only    (2 pts)
test 2: circles only   (2 pts) 
test 3: lines only     (2 pts)
test 4: mixed          (2 pts)
test 5: mixed          (2 pts)

Added by:kuszi
Date:2012-09-09
Time limit:0.200s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS PY_NBC
Resource:High School Programming League

hide comments
2017-06-30 15:53:40
lol I got 100... so its even better than 10 :D?
2017-06-09 20:32:35
it shows 0 in result and 0 in mem and time also ,that too in black background and in the menu it shows that i have solved the problem correctly.what does it mean..??anyone
2017-05-05 08:56:21
how to do this with c?
2017-03-11 21:18:59
Hardest part was parsing the input (Im on C).
2016-12-15 12:37:59
I keep getting "0 (limit: 2)", but ideone executes my prog and the answers are correct
Can somebody tell what should I do to eliminate this "0 (limit: 2)"...
2016-10-24 14:37:48
I got 10, but I didn't get Correct! Why?

Last edit: 2016-10-24 14:40:04
2016-10-12 09:15:37
In the same line I guess
I keep getting "0 (limit: 2)", but ideone executes my prog and the answers are correct
Can somebody tell what should I do to eliminate this "0 (limit: 2)"...
2016-10-07 20:55:33
do we have to read the inputs in the same line like:
p 3 3?
or can we use cin to read it like:
p
3
3?

Last edit: 2016-10-07 20:56:02
2016-09-27 11:44:26
an image for how to calculate mbr should be given
2016-09-23 07:46:12
What is "0 (limit: 2)"? can anyone explain...
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.