10198_ElectricFences

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

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

Pro.ID

10198

Title

Electric Fences

Title链接

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

AC

6

Submit

11

Ratio

54.55%

时间&空间限制

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

    Farmer John has decided to construct electric fences. He has fenced his fields into a number of bizarre shapes and now must find the optimal place to locate the electrical supply to each of the fences.

    A single wire must run from some point on each and every fence to the source of electricity. Wires can run through other fences or across other wires. Wires can run at any angle. Wires can run from any point on a fence (i.e., the ends or anywhere in between) to the electrical supply.

    Given the locations of all F (1 ≤ F ≤ 150) fences (fences are always parallel to a grid axis and run from one integer gridpoint to another, 0 ≤ X, Y ≤ 100), your program must calculate both the total length of wire required to connect every fence to the central source of electricity and also the optimal location for the electrical source.

    The optimal location for the electrical source might be anywhere in Farmer John's field, not necessarily on a grid point.

    输入

    Multiple test cases. For each case,

    The first line contains F, the number of fences.

    F subsequent lines each contain two X, Y pairs each of which denotes the endpoints of a fence.

    输出

    Description

    Farmer John has decided to construct electric fences. He has fenced his fields into a number of bizarre shapes and now must find the optimal place to locate the electrical supply to each of the fences.

    A single wire must run from some point on each and every fence to the source of electricity. Wires can run through other fences or across other wires. Wires can run at any angle. Wires can run from any point on a fence (i.e., the ends or anywhere in between) to the electrical supply.

    Given the locations of all F (1 ≤ F ≤ 150) fences (fences are always parallel to a grid axis and run from one integer gridpoint to another, 0 ≤ X, Y ≤ 100), your program must calculate both the total length of wire required to connect every fence to the central source of electricity and also the optimal location for the electrical source.

    The optimal location for the electrical source might be anywhere in Farmer John's field, not necessarily on a grid point.

    Input

    Multiple test cases. For each case,

    The first line contains F, the number of fences.

    F subsequent lines each contain two X, Y pairs each of which denotes the endpoints of a fence.

    Output

    For each case, on a single line, print three space-separated floating point numbers, each with a single decimal place. Presume that your computer's output library will round the number correctly.

    The three numbers are:

    • the X value of the optimal location for the electricity,

    • the Y value for the optimal location for the electricity, and

    • the total (minimum) length of the wire required.

    Sample Input

    3
    0 0 0 1
    2 0 2 1
    0 3 2 3

    Sample Output

    1.0 1.6 3.7

    Source

    样例输入

    3
    0 0 0 1
    2 0 2 1
    0 3 2 3

    样例输出

    1.0 1.6 3.7

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部