#P4545. [JSOI2013] 投影面积
[JSOI2013] 投影面积
Problem Description
For simplicity, the projection screen corresponds to a line segment in the 2D plane that is parallel to the axis and connects the point and the point .
JYY’s projector is located at the origin and faces the positive direction of the axis. It emits a light beam that is symmetric about the axis and has an opening angle of degrees ( is in degrees), as shown in the figure (the thick line is the projection screen, and the yellow area is the beam emitted by the projector).

There are obstacles in the lab. Each obstacle corresponds to a line segment in the 2D plane (we assume these obstacles have thickness ).
Some obstacles are non-reflective, so as long as a light ray hits such a segment, it will be completely absorbed (for example, the projection screen is non-reflective). Other obstacles are reflective on both sides: if a light ray hits such a segment, it will be reflected according to basic optics.
All obstacles do not touch each other, and they also do not touch the projection screen or the origin.
Light loses energy while traveling in air. Therefore, in JYY’s lab, after a light ray has traveled a distance of , it disappears.
Now JYY wants to know the ratio of the illuminated part on the projection screen to the total length of the screen.
Input Format
The first line contains one positive integer and two positive real numbers: .
The next lines each contain integers , indicating an obstacle segment connecting and . is either or . When , the obstacle is non-reflective; when , the obstacle is reflective on both sides.
The next line contains four integers , indicating the position of the projection screen. It is guaranteed that the second and fourth integers are the same.
Output Format
Output one real number between and , representing the ratio of the length of the illuminated part of the screen to the total screen length. The result should be accurate to digits after the decimal point.
2 150.0000 1000.0000
-60 165 50 165 0
110 25 130 120 1
-205 360 275 360
0.7443
Hint
Sample Explanation 1
As shown in the figure.

Constraints
For of the testdata, , , , and the absolute value of any input coordinate does not exceed .
The input guarantees that , and for any obstacle, .
The input also guarantees that for any light ray, it reflects at most times before disappearing or being absorbed.
Translated by ChatGPT 5