21526_ServerRelocation

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

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

Pro.ID

21526

Title

Server Relocation

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Michael has a powerful computer server that has hundreds of parallel processors and terabytes of main memory and disk space. Many important computations run continuously on this server, and power must be supplied to the server without interruption.

    Michael's server must be moved to accommodate new servers that have been purchased recently. Fortunately, Michael's server has two redundant power supplies---as long as at least one of the two power supplies is connected to an electrical outlet, the server can continue to run. When the server is connected to an electrical outlet, it can be moved to any location which is not further away from the outlet than the length of the cord used to connect to the outlet.

    Given which outlet Michael's server is plugged into initially and finally, and the locations of outlets in the server room, you should determine the smallest number of times you need to plug a cord into an electrical outlet in order to move the server while keeping the server running at all times. Note that, in the initial and final configuration, only one cord is connected to the power outlet.

    输入

    The first line of input is an integer giving the number of cases to follow. For each case, the first line is of the form

    OUTLETS  OUTLET_INITIAL  OUTLET_FINAL  LENGTH1  LENGTH2

    where

    * OUTLETS is the number of outlets in the server room (2 ≤ OUTLETS ≤ 1000).

    * OUTLET_INITIAL is the index (starting from 1) of the outlet the server is initially connected to.

    * OUTLET_FINAL is the index (starting from 1) of the outlet the server is finally connected to.

    * LENGTH1 and LENGTH2 are the positive lengths of the two power cords, with at most three digits of precision after the decimal point (0 < LENGTH1, LENGTH2 ≤ 30000).

    These are followed by OUTLETS lines giving the integer coordinates of the wall outlets, one per line, with the k-th line giving the location of the k-th outlet. All coordinates are specified as two integers (x- and y-coordinates) separated by a space, with absolute values at most 30000. You may assume that all coordinates are distinct, and that the initial outlet and the final outlet are different.

    输出

    Description

    Michael has a powerful computer server that has hundreds of parallel processors and terabytes of main memory and disk space. Many important computations run continuously on this server, and power must be supplied to the server without interruption.

    Michael's server must be moved to accommodate new servers that have been purchased recently. Fortunately, Michael's server has two redundant power supplies---as long as at least one of the two power supplies is connected to an electrical outlet, the server can continue to run. When the server is connected to an electrical outlet, it can be moved to any location which is not further away from the outlet than the length of the cord used to connect to the outlet.

    Given which outlet Michael's server is plugged into initially and finally, and the locations of outlets in the server room, you should determine the smallest number of times you need to plug a cord into an electrical outlet in order to move the server while keeping the server running at all times. Note that, in the initial and final configuration, only one cord is connected to the power outlet.

    Input

    The first line of input is an integer giving the number of cases to follow. For each case, the first line is of the form

    OUTLETS  OUTLET_INITIAL  OUTLET_FINAL  LENGTH1  LENGTH2

    where

    * OUTLETS is the number of outlets in the server room (2 ≤ OUTLETS ≤ 1000).

    * OUTLET_INITIAL is the index (starting from 1) of the outlet the server is initially connected to.

    * OUTLET_FINAL is the index (starting from 1) of the outlet the server is finally connected to.

    * LENGTH1 and LENGTH2 are the positive lengths of the two power cords, with at most three digits of precision after the decimal point (0 < LENGTH1, LENGTH2 ≤ 30000).

    These are followed by OUTLETS lines giving the integer coordinates of the wall outlets, one per line, with the k-th line giving the location of the k-th outlet. All coordinates are specified as two integers (x- and y-coordinates) separated by a space, with absolute values at most 30000. You may assume that all coordinates are distinct, and that the initial outlet and the final outlet are different.

    Output

    For each case, print the minimum number of times you need to plug a cord into an electrical outlet in order to move the server to the final location while keeping the server running at all times. If this is not possible, print "Impossible".

    Sample Input

    2
    4 1 4 2.000 1.000
    0 0
    0 4
    4 0
    4 4
    9 1 4 2.000 3.000
    0 7
    -6 2
    -3 3
    6 2
    -6 -3
    3 -3
    6 -3
    -3 -7
    0 -7

    Sample Output

    Impossible
    8

    Source

    样例输入

    2
    4 1 4 2.000 1.000
    0 0
    0 4
    4 0
    4 4
    9 1 4 2.000 3.000
    0 7
    -6 2
    -3 3
    6 2
    -6 -3
    3 -3
    6 -3
    -3 -7
    0 -7

    样例输出

    Impossible
    8

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部