22817_UndergroundCables

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

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

Pro.ID

22817

Title

Underground Cables

Title链接

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

AC

19

Submit

37

Ratio

51.35%

时间&空间限制

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

    A city wants to get rid of their unsightly power poles by moving their power cables underground. They have a list of points that all need to be connected, but they have some limitations. Their tunneling equipment can only move in straight lines between points, and they only have room for one underground cable at any location except at the given points so no two cables can cross.

    Given a list of points, what is the least amount of cable necessary to make sure that every pair or points is connected, either directly, or indirectly through other points?

    输入

    There will be several test cases in the data file. Each test case will begin with an integer N ( 2 ≤ N ≤ 1000 ), which is the number of points in the city. On each of the next N lines will be two integers, X and Y ( -1000 ≤ X, Y ≤ 1000 ), which are the ( X, Y ) locations of the N points.

    The input data will end with a line with a single 0.

    输出

    Description

    A city wants to get rid of their unsightly power poles by moving their power cables underground. They have a list of points that all need to be connected, but they have some limitations. Their tunneling equipment can only move in straight lines between points, and they only have room for one underground cable at any location except at the given points so no two cables can cross.

    Given a list of points, what is the least amount of cable necessary to make sure that every pair or points is connected, either directly, or indirectly through other points?

    Input

    There will be several test cases in the data file. Each test case will begin with an integer N ( 2 ≤ N ≤ 1000 ), which is the number of points in the city. On each of the next N lines will be two integers, X and Y ( -1000 ≤ X, Y ≤ 1000 ), which are the ( X, Y ) locations of the N points.

    The input data will end with a line with a single 0.

    Output

    For each test case, output a line containingsingle real number, representing the least amount of cable the city will need to connect all of its points. Print this number with to two decimal places precision.

    Sample Input

    4
    0 0
    0 10
    10 0
    10 10
    2
    0 0
    10 10
    0

    Sample Output

    30.00
    14.14

    Source

    样例输入

    4
    0 0
    0 10
    10 0
    10 10
    2
    0 0
    10 10
    0

    样例输出

    30.00
    14.14

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部