#Lutece0558. Darwin
Darwin
Migrated from Lutece 558 Darwin
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Darwin likes to write poetry about geometry. This is one of his most famous poetry:
Lie on a plane Two rectangles and many line segments.
Ah, gentle rectangles! All your sides parallel to X-axis or Y-axis. And one of you strictly encircles the other one Without any touch! The best place in the world The area between you two is.
Stupid line segments! Why you run across my darling rectangles? I will try all I can to clear you off the best place.
Darwin expressed his hatred towards line segments because they run into the area between the two rectangle (blue area in the above picture). He wanted to clear segments in that area. Given the rectangles and all the segments on the plane, please calculate the total length of segments Darwin needs to clear.
Note that segments are independent of each other, that is to say, Darwin has to clear the segments one by one even they may cover the same place. Segments coinciding with the boundaries of rectangles don't count into result.
Input
There are multiple test cases. The first line of the input will be an integer () indicating the number of test cases.
For each case, the first line contains eight integers: , , , , , , , . The lower left corner of the rectangle is at point , its length on the -axis is and on the -axis is . The lower left corner of the hole is at point , with size of .
An integer comes in the next line, which is the number of line segments. The following lines each with four integers give the line segments in this format: , representing the two ends, and , of each segments.
, , . All other numbers in the input would have absolute values no more than . For each segment, the two ends do not coincident.
Output
For each task, print Case #t: L
in a single line, in which is the number of this case starting from , and is the length Darwin needs to clear (rounded to two decimal place).
Samples
1
0 0 4 3 1 1 2 1
7
-1 0 1 0
0 1 2 3
1 3 1 -1
-1 4 1 4
2 0 4 3
2 1 4 1
4 0 2 2
Case #1: 10.25
Resources
10th UESTC Programming Contest Preliminary