#P4545. [JSOI2013] 投影面积

[JSOI2013] 投影面积

Problem Description

For simplicity, the projection screen corresponds to a line segment in the 2D plane that is parallel to the xx axis and connects the point (x1s,ys)(x_1^s, y^s) and the point (x2s,ys)(x_2^s, y^s).

JYY’s projector is located at the origin and faces the positive direction of the yy axis. It emits a light beam that is symmetric about the yy axis and has an opening angle of angang degrees (angang 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 nn obstacles in the lab. Each obstacle corresponds to a line segment in the 2D plane (we assume these obstacles have thickness 00).

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 lenlen, 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: n,ang,lenn, ang, len.

The next nn lines each contain 55 integers x1,x2,y1,y2,rx_1, x_2, y_1, y_2, r, indicating an obstacle segment connecting (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2). rr is either 00 or 11. When r=0r = 0, the obstacle is non-reflective; when r=1r = 1, the obstacle is reflective on both sides.

The next line contains four integers x1s,ys,x2s,ysx_1^s, y^s, x_2^s, y^s, 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 00 and 11, representing the ratio of the length of the illuminated part of the screen to the total screen length. The result should be accurate to 44 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 100%100\% of the testdata, 0n100 \leq n \leq 10, 0<ang1500 < ang \leq 150, 0<len1030 < len \leq 10^3, and the absolute value of any input coordinate does not exceed 10310^3.

The input guarantees that ys>0,x1s<x2sy^s > 0, x_1^s < x_2^s, and for any obstacle, y2<ys\vert y_2 \vert < y^s.

The input also guarantees that for any light ray, it reflects at most 3030 times before disappearing or being absorbed.

Translated by ChatGPT 5