22390_Cuttingapolygon

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

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

Pro.ID

22390

Title

Cutting a polygon

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Given is a simple but not necessarily convex polygon. Given is also a line in the plane. If the polygon is cut along the line then we may get several smaller polygons. Your task is to find the length of the cut, that is the total length of the segments in the intersection of the line and the polygon.

    输入

    Input consists of a number of cases. The data of each case appears on a number of input lines, the first of which contains two non negative integers n and m giving the number of the vertices of the polygon and the number of cutting lines to consider, 3 ≤ n ≤ 1000. The following n lines contain coordinates of the vertices of the polygon; each line contains the x and y coordinates of a vertex. The vertices are given either in clockwise or counterclockwise order. Each of the following m lines of input contains four numbers; these are x and y coordinates of the two points defining the cutting line. If a vertex of the polygon is closer than 10-8 to the cutting line then we consider that the vertex lies on the cutting line.

    Input is terminated by a line with n and m equal to 0.

    输出

    Description

    Given is a simple but not necessarily convex polygon. Given is also a line in the plane. If the polygon is cut along the line then we may get several smaller polygons. Your task is to find the length of the cut, that is the total length of the segments in the intersection of the line and the polygon.

    Input

    Input consists of a number of cases. The data of each case appears on a number of input lines, the first of which contains two non negative integers n and m giving the number of the vertices of the polygon and the number of cutting lines to consider, 3 ≤ n ≤ 1000. The following n lines contain coordinates of the vertices of the polygon; each line contains the x and y coordinates of a vertex. The vertices are given either in clockwise or counterclockwise order. Each of the following m lines of input contains four numbers; these are x and y coordinates of the two points defining the cutting line. If a vertex of the polygon is closer than 10-8 to the cutting line then we consider that the vertex lies on the cutting line.

    Input is terminated by a line with n and m equal to 0.

    Output

    For each cutting line, print the total length of the segments in the intersection of the line and the polygon defined for this test case, with 3 digits after the decimal point. Note: the perimiter of a polygon belongs the polygon.

    The picture above illustrates the first cutting line for the polygon from the sample.

    Sample Input

    9 5
    0 0
    0 2
    1 1
    2 2
    3 1
    4 2
    5 1
    6 2
    6 0
    -1 2 7.5 1
    0 1 6 1
    0 1.5 6 1.5
    0 2 6 1
    0 0 0 2
    0 0

    Sample Output

    2.798
    6.000
    3.000
    2.954
    2.000

    Source

    样例输入

    9 5
    0 0
    0 2
    1 1
    2 2
    3 1
    4 2
    5 1
    6 2
    6 0
    -1 2 7.5 1
    0 1 6 1
    0 1.5 6 1.5
    0 2 6 1
    0 0 0 2
    0 0

    样例输出

    2.798
    6.000
    3.000
    2.954
    2.000

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部