编程介的小学生 2017-11-08 03:00 采纳率: 20.5%
浏览 381
已结题

The Sad Triangles

Problem Description
There are n+m right triangles, some of them are isosceles triangles and the others are all triangles whose longer leg (the sides adjacent to the right angle are called legs) is three times the length of the shorter one. Now we put the triangles on the x>=0, y>=0 part of the plane, and make sure the shorter legs match the x-axis. We call the triangle faces left when the slope of the hypotenuse (the side opposite the right angle is called the hypotenuse) is positive, and the triangle faces right when the slope is negative.
In the first picture, triangle a has a longer leg three times the length of the shorter one, faces right and triangle b is an isosceles triangle, faces left.
Now given the position of each triangle, you need to use a rectangle with L width (the side parallel to x-axis) and limitless height(the side parallel to y-axis) to cover the triangles, if a triangle overlaps with another one, we count the area overlapped only once.
So what's the maximum area can be covered.
It is guaranteed that the x-coordinate of every point is non-negative integer and won't be larger than 100000. We can put the rectangle anywhere.

Input
The first line comes with one integer T (T<15) which denotes the test cases.
In the first line of each case, there are 3 integers n, m , L(1<=n+m<=100000, 1<=L<=100000), indicates there are n triangles faces left and m triangles faces right, and the width of the rectangle is L.In the following n lines describe the triangles face left. Each line contains three integers xi, ki, li, indicates the right angle point is at the position (xi, 0), (0<=xi<=100000) ,the type of the triangle(ki=1 when the triangle is isosceles triangle, ki=3 when the longer leg is three times the length of the shorter one), and the length of the shorter leg.
In the following m lines describe the triangles face right. Each line contains three integers xi, ki, li, which has similar meanings as described above.
Different test cases are separated by a blank line.

Output
For each test case, output one line.
First, output "Case #C: ", where C is the number of test case, from 1 to T. Then output the maximum areas that can be covered. The answer should be rounded to 6 digits after the decimal point.

Sample Input
1
1 1 2
1 1 1
2 1 1

Sample Output
Case #1: 0.750000

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Stata 面板数据模型选择
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 请问这个是什么意思?
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用