21519_WalkinthePark

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

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

Pro.ID

21519

Title

Walk in the Park

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 6000/3000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    You are responsible for inspecting the trees located in a park, to make sure they remain healthy. The location of each tree is given to you as a point in the twodimensional plane, distinct from that of every other tree. Due to recentlyreplanted grass, you are only allowed to walk through the park along a collection of paths. Each path is described by an infinite-length horizontal or vertical line in the two-dimensional plane. No tree lies on any path.

    You are concerned that it may not be possible to view all the trees in the park from the paths. In particular, a tree is visible only if you can view it by standing on some path while facing in a direction perpendicular to that path; there must be no intervening tree that obstructs your view. Given the geometrical configuration of the park, please report the number of visible

    输入

    There will be multiple input sets. For each input set, the first line will contain two integers, N and M , ( 0 < N, M ≤ 100000 ), separated by a space. N is the number of trees, and M is the number of paths.

    The next N lines each contain two space-separated integers, X and Y , specifying the coordinates of a tree. X and Y may be any 32-bit integers.

    The next M lines each describe a path (a vertical or horizontal line). They have the form x = K or y = K , with no spaces. K may be any 32-bit integer. x and y will be lower case.

    End of the input is signified by a line with two space-separated 0's.

    输出

    Description

    You are responsible for inspecting the trees located in a park, to make sure they remain healthy. The location of each tree is given to you as a point in the twodimensional plane, distinct from that of every other tree. Due to recentlyreplanted grass, you are only allowed to walk through the park along a collection of paths. Each path is described by an infinite-length horizontal or vertical line in the two-dimensional plane. No tree lies on any path.

    You are concerned that it may not be possible to view all the trees in the park from the paths. In particular, a tree is visible only if you can view it by standing on some path while facing in a direction perpendicular to that path; there must be no intervening tree that obstructs your view. Given the geometrical configuration of the park, please report the number of visible

    Input

    There will be multiple input sets. For each input set, the first line will contain two integers, N and M , ( 0 < N, M ≤ 100000 ), separated by a space. N is the number of trees, and M is the number of paths.

    The next N lines each contain two space-separated integers, X and Y , specifying the coordinates of a tree. X and Y may be any 32-bit integers.

    The next M lines each describe a path (a vertical or horizontal line). They have the form x = K or y = K , with no spaces. K may be any 32-bit integer. x and y will be lower case.

    End of the input is signified by a line with two space-separated 0's.

    Output

    For each input set, print a single line containing one integer, specifying the number of visible trees. There should be no blank lines between outputs.

    Sample Input

    6 3
    -1 3
    4 2
    6 2
    6 3
    6 4
    4 3
    x=0
    y=-1
    y=5
    1 2
    2 3
    x=5
    y=5
    0 0

    Sample Output

    5
    1

    Source

    样例输入

    6 3
    -1 3
    4 2
    6 2
    6 3
    6 4
    4 3
    x=0
    y=-1
    y=5
    1 2
    2 3
    x=5
    y=5
    0 0

    样例输出

    5
    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部