21567_Tractor

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

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

Pro.ID

21567

Title

Tractor

Title链接

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

AC

2

Submit

4

Ratio

50.00%

时间&空间限制

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

    After a long day of work, Farmer John completely forgot that he left his tractor in the middle of the field.  His cows, always up to no good, decide to play a prank of Farmer John: they deposit N bales of hay (1≤ N ≤ 50,000) at various locations in the field, so that Farmer John cannot easily remove the tractor without first removing some of the bales of hay.

    The location of the tractor, as well as the locations of the N hay bales, are all points in the 2D plane with integer coordinates in the range 1..1000.  There is no hay bale located at the initial position of the tractor.  When Farmer John drives his tractor, he can only move it in directions that are parallel to the coordinate axes (north, south, east, and west), and it must move in a sequence of integer amounts.  For example, he might move north by 2 units, then east by 3 units.  The tractor cannot move onto a point occupied by a hay bale.

    Please help Farmer John determine the minimum number of hay bales he needs to remove so that he can free his tractor (that is, so he can drive his tractor to the origin of the 2D plane).

    输入

    多测试。

    * Line 1: Three space-separated integers: N, and the (x, y) starting location of the tractor.

    * Lines 2..1+N: Each line contains the (x, y) coordinates of a bale of hay.

    输出

    Description

    After a long day of work, Farmer John completely forgot that he left his tractor in the middle of the field.  His cows, always up to no good, decide to play a prank of Farmer John: they deposit N bales of hay (1≤ N ≤ 50,000) at various locations in the field, so that Farmer John cannot easily remove the tractor without first removing some of the bales of hay.

    The location of the tractor, as well as the locations of the N hay bales, are all points in the 2D plane with integer coordinates in the range 1..1000.  There is no hay bale located at the initial position of the tractor.  When Farmer John drives his tractor, he can only move it in directions that are parallel to the coordinate axes (north, south, east, and west), and it must move in a sequence of integer amounts.  For example, he might move north by 2 units, then east by 3 units.  The tractor cannot move onto a point occupied by a hay bale.

    Please help Farmer John determine the minimum number of hay bales he needs to remove so that he can free his tractor (that is, so he can drive his tractor to the origin of the 2D plane).

    Input

    多测试。

    * Line 1: Three space-separated integers: N, and the (x, y) starting location of the tractor.

    * Lines 2..1+N: Each line contains the (x, y) coordinates of a bale of hay.

    Output

    * Line 1: The minimum number of bales of hay Farmer John must remove in order to open up a path for his tractor to move to the origin.

    Sample Input

    7 6 3
    6 2
    5 2
    4 3
    2 1
    7 3
    5 4
    6 4

    Sample Output

    1

    Hint

    INPUT DETAILS:

    The tractor starts at (6,3).  There are 7 bales of hay, at positions (6,2), (5,2), (4,3), (2,1), (7,3), (5,4), and (6,4).

    OUTPUT DETAILS:

    Farmer John only needs to remove one bale of hay to free his tractor.

    Source

    样例输入

    7 6 3
    6 2
    5 2
    4 3
    2 1
    7 3
    5 4
    6 4

    样例输出

    1

    提示

    INPUT DETAILS:

    The tractor starts at (6,3).  There are 7 bales of hay, at positions (6,2), (5,2), (4,3), (2,1), (7,3), (5,4), and (6,4).

    OUTPUT DETAILS:

    Farmer John only needs to remove one bale of hay to free his tractor.


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部