您的位置:首页 > 其它

UVA 10397 - Connect the Campus 翻译

2014-12-12 13:55 435 查看
Problem E

Connect the Campus

Input: standard input

Output: standard output

Time Limit: 2 seconds

Many new buildings are under construction on the campus of the University of Waterloo.

许多新的建筑物在建造在滑铁卢大学的校园。

The university has hired bricklayers, electricians, plumbers, and a computer programmer.

学校聘请了砌砖工,电工,水管工,和一个计算机程序员。

A computer programmer? Yes, you have been hired to ensure that each building is connected to every other building (directly or indirectly) through the campus network of communication cables.

一个计算机程序员?是的,你被雇佣来确保每个建筑连接到每个建筑(直接或间接)通过通讯电缆的校园网络。

We will treat each building as a point specified by an x-coordinate and a y-coordinate.

我们将把每一个建筑物作为一个点的X坐标和y坐标指定。

Each communication cable connects exactly two buildings, following a straight line between the buildings.

每个通信电缆连接两个建筑物,在建筑物之间的一条直线。

Information travels along a cable in both directions.

信息沿着两个方向的电缆。

Cables can freely cross each other, but they are only connected together at their endpoints (at buildings).

电缆可以自由地相互交叉,但他们只连接在一起,在它们的端点(建筑物)。

You have been given a campus map which shows the locations of all buildings and existing communication cables.

你已经给了一个校园地图,显示了所有建筑物和现有的通信电缆的位置。

You must not alter the existing cables.

你不能改变现有的电缆。

Determine where to install new communication cables so that all buildings are connected.

确定要安装新的通信电缆,连接所有大楼。

Of course, the university wants you to minimize the amount of new cable that you use.

当然,大学要你减少你使用新的电缆的数量。

【最小生成树 <wbr>Prim/Kruskal&并查集】

Fig: University of Waterloo Campus 图:滑铁卢大学校园

Input

The input file describes several test case. The description of each test case is given below:

输入文件描述了几个测试用例。每个测试案例的描述如下:

The first line of each test case contains the number of buildings N (1<=N<=750). The buildings are labeled from 1 to N.

每个测试案例的第一行包含建筑的数量N(1≤n≤750)。建筑标记从1到N,

The next N lines give the x and y coordinates of the buildings.

以下N行给X和Y坐标的建筑物。

These coordinates are integers with absolute values at most 10000.

这些坐标是绝对值的整数 最多10000

No two buildings occupy the same point.

没有两个建筑占据同一点。

After that there is a line containing the number of existing cables M (0 <= M <= 1000) followed by M lines describing the existing cables.

之后有一行包含现有的电缆的数量(0≤m≤1000)随后的M行描述现有的电缆。

Each cable is represented by two integers: the building numbers which are directly connected by the cable.

每个电缆是由两个整数表示:这是由电缆直接连接的门牌号码。

There is at most one cable directly connecting each pair of buildings.

至多有一个电缆直接连接每对建筑物。

Output

For each set of input, output in a single line the total length of the new cables that you plan to use, rounded to two decimal places.

对每一组输入,输出一行新的电缆总长度,你计划使用,圆形到两位小数。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: