10171_ClosedFences

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

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

Pro.ID

10171

Title

Closed Fences

Title链接

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

AC

4

Submit

16

Ratio

25.00%

时间&空间限制

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

    A closed fence in the plane is a set of non-crossing, connected line segments with N corners (3 < N < 200). The corners or vertices are each distinct and are listed in counter-clockwise order in an array { xi, yi}, i in ( 1 .. N ).

    Every pair of adjacent vertices defines a side of the fence. Thus { xi , yi , xi+1 , yi+1} is a side of the fence for all i in ( 1 .. N ). For our purposes, N+1 = 1, so that the first and last vertices making the fence closed.

    Here is a typical closed fence and a point x, y:

                             * x3,y3
                x5,y5  / \
    x,y *          *   /   \
                   / \ /     \
                   /   *       \
              x6,y6*   x4,y4     \
                    |              \
                     |               \
                       x1,y1*----------------* x2,y2

    Write a program which will do the following:

    • Test an ordered list of vertices { xi, yi}, i in ( 1 .. N ) to see if the array is a valid fence.

    • Find the set of fence sides that a person (with no height) who is standing in the plane at position ( x , y ) can "see" when looking at the fence. The location x, y may fall anywhere not on the fence.

    A fence side can be seen if there exists a ray that connects ( x , y ) and any point on the side, and the ray does not intersect any other side of the fence. A side that is parallel to the line of sight is not considered visible. In the figure, above the segments (x3, y3)-(x4, y4); (x5, y5)-(x6, y6); and (x6, y6)-(x1, y1) are visible or partially visible from x, y.

    输入

    Line 1:   N, the number of corners in the fence

    Line 2:    Two space-separated integers, x and y, that are the location of the observer. Both integers will fit into 16 bits.

    Line 3-N+2:  A pair of space-separated integers denoting the X, Y location of the corner. The pairs are given in counterclockwise order. Both integers are no larger than 1000 in magnitude.

    输出

    Description

    A closed fence in the plane is a set of non-crossing, connected line segments with N corners (3 < N < 200). The corners or vertices are each distinct and are listed in counter-clockwise order in an array { xi, yi}, i in ( 1 .. N ).

    Every pair of adjacent vertices defines a side of the fence. Thus { xi , yi , xi+1 , yi+1} is a side of the fence for all i in ( 1 .. N ). For our purposes, N+1 = 1, so that the first and last vertices making the fence closed.

    Here is a typical closed fence and a point x, y:

                             * x3,y3
                x5,y5  / \
    x,y *          *   /   \
                   / \ /     \
                   /   *       \
              x6,y6*   x4,y4     \
                    |              \
                     |               \
                       x1,y1*----------------* x2,y2

    Write a program which will do the following:

    • Test an ordered list of vertices { xi, yi}, i in ( 1 .. N ) to see if the array is a valid fence.

    • Find the set of fence sides that a person (with no height) who is standing in the plane at position ( x , y ) can "see" when looking at the fence. The location x, y may fall anywhere not on the fence.

    A fence side can be seen if there exists a ray that connects ( x , y ) and any point on the side, and the ray does not intersect any other side of the fence. A side that is parallel to the line of sight is not considered visible. In the figure, above the segments (x3, y3)-(x4, y4); (x5, y5)-(x6, y6); and (x6, y6)-(x1, y1) are visible or partially visible from x, y.

    Input

    Line 1:   N, the number of corners in the fence

    Line 2:    Two space-separated integers, x and y, that are the location of the observer. Both integers will fit into 16 bits.

    Line 3-N+2:  A pair of space-separated integers denoting the X, Y location of the corner. The pairs are given in counterclockwise order. Both integers are no larger than 1000 in magnitude.

    Output

    If the sequence is not a valid fence, the output is a single line containing the word "NOFENCE".

    Otherwise, the output is a listing of visible fence segments, one per line, shown as four space-separated integers that represent the two corners. Express the points in the segment by showing first the point that is earlier in the input, then the point that is later. Sort the segments for output by examining the last point and showing first those points that are earlier in the input. Use the same rule on the first of the two points in case of ties.

    Sample Input

    13
    5 5
    0 0
    7 0
    5 2
    7 5
    5 7
    3 5
    4 9
    1 8
    2 5
    0 9
    -2 7
    0 3
    -3 1

    Sample Output

    7
    0 0 7 0
    5 2 7 5
    7 5 5 7
    5 7 3 5
    -2 7 0 3
    0 0 -3 1
    0 3 -3 1

    Source

    样例输入

    13
    5 5
    0 0
    7 0
    5 2
    7 5
    5 7
    3 5
    4 9
    1 8
    2 5
    0 9
    -2 7
    0 3
    -3 1

    样例输出

    7
    0 0 7 0
    5 2 7 5
    7 5 5 7
    5 7 3 5
    -2 7 0 3
    0 0 -3 1
    0 3 -3 1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部