Tree Lighting
Time limit1sMemory limit128 MB
A point light shines a bounded wedge upward through absorbing and mirrored segments, and you report the lit percentage of a horizontal house front.
- Level
Hard8 of 10
- Topics
- Geometry, Simulation, Intervals
- Solved
- No attempts yet
Problem
Arbor Day is a big day for the Pine family of Chestnut Grove. Every year the family, led by their father Hickory, covers the front yard and the front of the house with hundreds of Arbor Day decorations. At night Hickory aims a yard light at the front of the house so that people walking by get a good look at the whole display.
Some decorations block the light and drop shadows on the front of the house. Others act like mirrors and send light back onto parts of the wall the direct beam never reaches. In one layout the light spreads out from a point low in the yard, a horizontal decoration in the middle swallows the middle of the beam, and a decoration on the right reflects part of it back, so about 75% of the front of the house ends up lit.
The decorations change from year to year, so Hickory wants one general method that takes a layout and reports how much of the front of his house will be lit.
Light and decorations follow these rules.
- The light sits at the origin. It spreads in a wedge symmetric about the positive axis, opening degrees on either side.
- A ray dies once the total distance it has travelled passes . That total is the sum of the lengths of every leg between reflections.
- Every decoration is a segment of zero thickness. A non-reflective decoration absorbs any ray that reaches it. A reflective decoration is mirrored on both sides and sends a ray back at the angle it arrived. Neither kind lets a ray pass through.
- The front of the house is a horizontal segment above every decoration, and it stops any ray that reaches it.
Report what percentage of the length of the front of the house is reached by at least one ray.
Input
The input holds several test cases.
Each test case starts with a line holding an integer , a real number and a real number . is the number of decorations (). is the spread of the light in degrees (). The light is always at the origin, and the beam is symmetric about the positive axis, opening degrees on either side. is the greatest distance any one ray can travel. Past that distance the beam is too weak to add anything to the lighting of the house.
Each of the next lines holds five integers . The first four give the endpoints of a decoration. is for a non-reflective decoration and for a reflective one.
After those lines comes a single line with four integers giving the endpoints of the front of the house, with .
No decoration meets another decoration, the front of the house, or the origin, and no decoration has a coordinate larger than the of the front of the house. Every coordinate is between and . In each test case the placement of the decorations and the value of keep the total number of reflections at or fewer.
A line holding 0 0.0 0.0 ends the input. It is not a test case.
Output
For each test case print one line in this form.
Case k: p
is the number of the test case, counting from , and is the percentage of the front of the house that is lit. Round to the nearest hundredth, round a value that lands exactly halfway up, and print exactly two digits after the decimal point. No test case has an answer within of a rounding boundary.