10084_ConnectedGheeves

2022-5-16 18:16| 发布者: Hocassian| 查看: 68| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504527691700-Problem List-采集的数据-后羿采集器.html

Pro.ID

10084

Title

Connected Gheeves

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10084

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    Gheeves (plural of gheef) are some objects similar to funnels. We define a gheef as a two dimensional object specified by a sequence of points (p1, p2, ..., pn) with the following conditions:

    • 3 ≤ n ≤ 1000

    • If a point pi is specified by the coordinates (xi, yi), there is an index 1 < c < n such that y1 > y2 > ... > yc and yc < yc+1 < yc+2 < ... < yn. pc is called the cusp of the gheef.

    • For all 1 ≤ i < c, xi < xc and for all c < in, xi > xc.

    • For 1 < i < c, the amount of rotation required to rotate pi-1 around pi in clockwise direction to become co-linear with pi and pi+1, is greater than 180 degrees. Likewise, for c < i < n, the amount of rotation required to rotate pi-1 around pi in clockwise rotation to become co-linear with pi and pi+1, is greater than 180 degrees.

    • The set of segments joining two consecutive points of the sequence intersect only in their endpoints.

    For example, the following figure shows a gheef of six points with c = 4:

    We call the sequence of segments (p1p2, p2p3, ..., pn-1pn), the body of the gheef. In this problem, we are given two gheeves P = (p1, p2, ..., pn) and Q = (q1, q2, ..., qm), such that all x coordinates of pi are negative integers and all x coordinates of qi are positive integers. Assuming the cusps of the two gheeves are connected with a narrow pipe, we pour a certain amount of water inside the gheeves. As we pour water, the gheeves are filled upwards according to known physical laws (the level of water in two gheeves remains the same). Note that in the gheef P, if the level of water reaches min(y1, yn), the water pours out of the gheef (the same is true for the gheef Q). Your program must determine the level of water in the two gheeves after pouring a certain amount of water. Since we have defined our problem in two dimensions, the amount of water is measured in terms of area it fills. Note that the volume of pipe connecting cusps is considered as zero.

    输入

    The first number in the input line, t is the number of test cases. Each test case is specified on three lines of input. The first line contains a single integer a (1 ≤ a ≤ 100000) which specifies the amount of water poured into two gheeves. The next two lines specify the two gheeves P and Q respectively, each of the form k x1 y1 x2 y2 ... xk yk where k is the number of points in the gheef (n for P and m for Q), and the xiyi sequence specify the coordinates of the points in the sequences.

    输出

    Description

    Gheeves (plural of gheef) are some objects similar to funnels. We define a gheef as a two dimensional object specified by a sequence of points (p1, p2, ..., pn) with the following conditions:

    • 3 ≤ n ≤ 1000

    • If a point pi is specified by the coordinates (xi, yi), there is an index 1 < c < n such that y1 > y2 > ... > yc and yc < yc+1 < yc+2 < ... < yn. pc is called the cusp of the gheef.

    • For all 1 ≤ i < c, xi < xc and for all c < in, xi > xc.

    • For 1 < i < c, the amount of rotation required to rotate pi-1 around pi in clockwise direction to become co-linear with pi and pi+1, is greater than 180 degrees. Likewise, for c < i < n, the amount of rotation required to rotate pi-1 around pi in clockwise rotation to become co-linear with pi and pi+1, is greater than 180 degrees.

    • The set of segments joining two consecutive points of the sequence intersect only in their endpoints.

    For example, the following figure shows a gheef of six points with c = 4:

    We call the sequence of segments (p1p2, p2p3, ..., pn-1pn), the body of the gheef. In this problem, we are given two gheeves P = (p1, p2, ..., pn) and Q = (q1, q2, ..., qm), such that all x coordinates of pi are negative integers and all x coordinates of qi are positive integers. Assuming the cusps of the two gheeves are connected with a narrow pipe, we pour a certain amount of water inside the gheeves. As we pour water, the gheeves are filled upwards according to known physical laws (the level of water in two gheeves remains the same). Note that in the gheef P, if the level of water reaches min(y1, yn), the water pours out of the gheef (the same is true for the gheef Q). Your program must determine the level of water in the two gheeves after pouring a certain amount of water. Since we have defined our problem in two dimensions, the amount of water is measured in terms of area it fills. Note that the volume of pipe connecting cusps is considered as zero.

    Input

    The first number in the input line, t is the number of test cases. Each test case is specified on three lines of input. The first line contains a single integer a (1 ≤ a ≤ 100000) which specifies the amount of water poured into two gheeves. The next two lines specify the two gheeves P and Q respectively, each of the form k x1 y1 x2 y2 ... xk yk where k is the number of points in the gheef (n for P and m for Q), and the xiyi sequence specify the coordinates of the points in the sequences.

    Output

    The output contains t lines, each corresponding to an input test case in that order. The output line contains a single integer L indicating the final level of water, expressed in terms of y coordinates rounded to three digits after decimal points.

    Sample Input
    2
    25
    3 -30 10 -20 0 -10 10
    3 10 10 20 0 30 10
    25
    3 -30 -10 -20 -20 -10 -10
    3 10 10 20 0 30 10
    Sample Output
    3.536
    -15.000
    Source

    样例输入

    2
    25
    3 -30 10 -20 0 -10 10
    3 10 10 20 0 30 10
    25
    3 -30 -10 -20 -20 -10 -10
    3 10 10 20 0 30 10

    样例输出

    3.536
    -15.000

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部