## ULASER - Union Laser

no tags

Doctor Y, a leading expert in the field of boxology, is investigating the properties of boxen with his expensive super-precision laser. In particular, he plans to position the laser inside the union of a bunch of boxen, and see where the beam collides with itself.

Since Doctor Y blew all his cash on the laser, he can’t actually afford to purchase boxen to conduct his experiment – instead, he will simulate it on his old computer, which uses an integer grid system. He will give his computer an integer $N$, the number of boxen ($1 \leq N \leq 10,000$), as well as their descriptions. Each box is described by 4 integers, $x_1$, $y_1$, $x_2$, and $y_2$, and is an axis-aligned rectangle with coordinates ($x_1$, $y_1$) and ($x_2$, $y_2$) describing a pair of its opposite corners. Boxen may overlap with one another. He will also input the location of the laser ($A$, $B$), such that it will be positioned strictly within at least one of the boxen. The laser points down and right at a 45° angle. All coordinates have absolute values of at most $3000$.

As it turns out, boxen are made of a perfectly reflective material (a fact which Doctor Y will discover upon completion of his experiment) – as such, whenever the laser beam hits the edge of the union of the boxen, it bounces off. For example, if it hits a vertical edge from the left, it bounces to the right, with the up-down direction preserved. If it hits a corner head-on, it will reverse direction, hence colliding with itself right at the corner. Normally, light travels quite fast, but due to the mysterious properties of boxen, the speed of light when inside a box union is only √2 units/second.

Doctor Y plans to use his computer to simulate the path of the laser and see when and where it first collides with itself, but there’s one problem – he doesn't know how to program! Offering non-cafeteria food, he lures a desperate Waterloo student into his lab, where he forces him (or her?) to write the laser simulation program. That’s you.

### Input

Line $1$: 1 integer, $N$

Line $2$: 2 integers, $A$ and $B$

Next $N$ lines: 4 integers, $x_1$, $y_1$, $x_2$, and $y_2$, describing the coordinates of each box

### Output

If the laser beam never collides with itself or the laser, simply output “Time limit exceeded”.

If the laser beam collides with the actual laser (at coordinates ($A$, $B$)) before it collides with another location through which the beam has already passed, the first line of output should consist of a single number – the amount of time that passes before laser beam collides with the laser, in seconds. The second line should read “Broken equipment”.

Otherwise, the first line of output should consist of a single number – the amount of time that passes before laser beam first collides with itself, in seconds. The second line should contain a pair of numbers – the x and y coordinates of where this takes place.

Each number should be rounded off to 1 decimal place.

### Example

Input:
7
0 4
-1 5 1 -1
0 -2 4 2
0 -4 1 2
2 -4 5 -1
5 2 7 4
3 -5 4 -4
0 -6 3 -4
Output:
12.0
0.0 0.0
Explanation of Sample:

The grid looks like this:

The filled-in squares represent squares that are part of at least one box – together, they make up the box union. Note that the union can have holes in it, and that it can be disjoint.

The blue lines denote the boundaries of the union – these are the lines that the laser can bounce off of.

The yellow lines are edges of boxen that do not contribute to the union – the laser can go through these freely.

The red diamond is the position of the laser, and the red line is the path that the laser beam follows. Note that when it bounces off the corner at (2,-2), since it didn’t hit it head-on, it is the same as bouncing off of a horizontal edge.

Following the path of the laser beam, it can be seen that it collides with itself at (0,0). Before this, it has travelled 12√2 units, which takes exactly 12 seconds.

More Examples:

If the laser were positioned at (0,3), the output should be:

12.00.0 -1.0

If the laser were positioned at (0,1), the output should be:

5.05.0 -4.0

If the laser were positioned at (0,0), the output should be:

8.0Broken equipment

hide comments
 [Rampage] Blue.Mary: 2016-01-27 12:32:33 Really nice problem! Enjoy it very much!! Sumeet Agrawal: 2014-08-12 11:38:31 @Jacob Plachta can you see the code in java 12128917 it is showing tle . RE: You time out even with a 30-second time limit. Last edit: 2014-08-21 19:27:13 Sumeet Agrawal: 2014-07-30 19:47:18 Can you tell me what is the time limit exceeded case RE: Several large ones, and you also get a runtime error on one. Last edit: 2014-07-30 20:08:30 Min_25: 2014-03-17 02:58:57 enjoyed it very much. :) RE: Thanks! Last edit: 2014-03-18 04:35:09

 Added by: SourSpinach Date: 2013-05-08 Time limit: 3s Source limit: 50000B Memory limit: 1536MB Cluster: Cube (Intel G860) Languages: All except: ASM64 Resource: Own problem