#P6106. [Ynoi2010] Self Adjusting Top Tree
[Ynoi2010] Self Adjusting Top Tree
Problem Description
There are line segments on the plane.
There are queries. In each query, an axis-aligned rectangle is given. You need to find the ratio of: the sum, over every segment that intersects the rectangle, of the length of the intersection between that segment and the rectangle, to the sum of the lengths of all segments. Output the answer such that the relative error or absolute error compared with the standard answer is at most .
Each segment is given in the form , meaning a segment with endpoints and . It is guaranteed that any two segments have no intersection point and no overlapping part, and that .
Each rectangle is given in the form , meaning the rectangle . It is guaranteed that and .
Input Format
The first line contains an integer .
The next lines each contain four integers separated by spaces: , describing a line segment.
The next line contains an integer .
The next lines each contain four integers separated by spaces: , describing the query rectangle.
Output Format
For each query, output one line: a decimal number between and , representing the answer.
2
1 1 4 4
2 1 4 3
4
1 1 6 6
1 1 3 3
2 1 3 3
1 2 2 4
1
0.6
0.4
0
Hint
Idea: nzhtl1477 & ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078.
For of the testdata, and .
Translated by ChatGPT 5