| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 691 人关注过本帖
标题:哪位大虾帮忙做一下着道题(数据结构c语言)
只看楼主 加入收藏
Romy
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-17
收藏
 问题点数:0 回复次数:2 
哪位大虾帮忙做一下着道题(数据结构c语言)

Electric Wiring

Bill is designing electric wiring for his new house. First of all, he has fixed the positions of several electrical outlets on the walls. To neatly connect any pair of outlets, he would make sure that the wire is always imbedded in the walls or the floor, and is parallel to at least one side of the wall. Naturally he wants to minimize the total length of wire he must buy to have all the outlets connected.

By the way, do not forget that there is a door for every room. The wire must not cross the door. Figure 1 shows a possible setting in a room with 4 outlets.

Input Specification:

Your program must read test cases from a file “input.txt”. The input file consists of several test cases. For each test case, the first line contains 4 triples (x1, y1, z1) ... (x4, y4, z4) which are the coordinates of the four corners of a rectangular door. The second line contains size of the room, (Lx, Ly, Lz), and a positive integer N (<=20). Then N lines of coordinates (xi, yi, zi) of the outlets follow. Proceed until the end of file.

It is assumed that the cuboid room is completely in the first quadrant of the Cartesian coordinates with one of its corners at the origin, and the floor sits in x-y plane. It is guaranteed that each outlet belongs to one and only one of the four walls and no outlet is placed on the door. The two ends of a segment of wire must connect to outlets only.

Output Specification:

For each test case, output to a file “output.txt” in one line the nearest integer length of wire which can have all the outlets connected.

Sample Input:

0 0 0 0 0 3 1.5 0 0 1.5 0 3

10 10 10 4

0 1 3.3

2.5 0 2

5 0 0.8

5 10 1

Sample Output:

21

Hint: Take each outlet as a node in a graph. Implement a greedy algorithm to find the minimum spanning tree.

拜谢了!!

搜索更多相关主题的帖子: 数据结构 c语言 
2005-12-17 14:34
Romy
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-17
收藏
得分:0 
高手进来说一下, 就说说那个距离怎么求的呀
2005-12-17 16:58
Romy
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-17
收藏
得分:0 

哪位好人进来一下, 帮个忙的呀

2005-12-17 20:11
快速回复:哪位大虾帮忙做一下着道题(数据结构c语言)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050774 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved