博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Poj(2349),最小生成树的变形
阅读量:4577 次
发布时间:2019-06-08

本文共 2401 字,大约阅读时间需要 8 分钟。

题目链接:

Arctic Network
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 17032   Accepted: 5441

Description

The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceiver and some outposts will in addition have a satellite channel. 
Any two outposts with a satellite channel can communicate via the satellite, regardless of their location. Otherwise, two outposts can communicate by radio only if the distance between them does not exceed D, which depends of the power of the transceivers. Higher power yields higher D but costs more. Due to purchasing and maintenance considerations, the transceivers at the outposts must be identical; that is, the value of D is the same for every pair of outposts. 
Your job is to determine the minimum D required for the transceivers. There must be at least one communication path (direct or indirect) between every pair of outposts.

Input

The first line of input contains N, the number of test cases. The first line of each test case contains 1 <= S <= 100, the number of satellite channels, and S < P <= 500, the number of outposts. P lines follow, giving the (x,y) coordinates of each outpost in km (coordinates are integers between 0 and 10,000).

Output

For each case, output should consist of a single line giving the minimum D required to connect the network. Output should be specified to 2 decimal points.

Sample Input

12 40 1000 3000 600150 750

Sample Output

212.13

Source

 
题意:1案例数,2个点是可以用无线的(用无线的点,到任何点的距离不受限制),4个点,下面是坐标,求最小生成树中的最大权值,和之前的不同点是在权值为0的点是不确定的。
思路:照样求最小生成树,有2个点的距离为0,即可以在最小生成树中删掉两条最长的边。最靠后的那条边就是最大的权值。
#include 
#include
#include
#include
using namespace std;int x[550];int y[550];struct Edge { int u,v; double w;}edge[550*550];int father[550];int Find_Set(int x){ if(x!=father[x]) father[x] = Find_Set(father[x]); return father[x];}int cmp (Edge a,Edge b){ return a.w < b.w;}double ans[550];int main(){ //freopen("input.txt","r",stdin); int cases; scanf("%d",&cases); while(cases--) { memset(ans,0,sizeof(ans)); int s,n; scanf("%d%d",&s,&n); for(int i=0;i

 

转载于:https://www.cnblogs.com/TreeDream/p/5748110.html

你可能感兴趣的文章
微信公众平台开发2-access_token获取及应用(含源码)
查看>>
JavaScript数据结构-19.拓扑排序
查看>>
TeeChart取消3D
查看>>
oracle查看数据库版本和字符集
查看>>
mybatis调用mysql存储过程(返回值问题)
查看>>
InnoDB undo log物理结构的初始化
查看>>
linux常见问题集锦-2
查看>>
[转载]深入理解ASP.NET MVC之ActionResult
查看>>
Day74
查看>>
廖雪峰Java8JUnit单元测试-2使用JUnit-3参数化测试
查看>>
5个免费项目管理工具
查看>>
codeforces 502 g The Tree
查看>>
树的一些问题
查看>>
绑定bindchange事件的微信小程序swiper闪烁,抖动问题解决,(将微信小程序切换到后台一段时间,再打开微信小程序,会出现疯狂循环轮播,造成抖动现象)...
查看>>
用expect 实现切换用户时自动输入密码
查看>>
javascript 获取当前对象
查看>>
设计模式(三)---抽象工厂模式
查看>>
bzoj1061: [Noi2008]志愿者招募
查看>>
推荐一款开源、免费的标记语言转换工具,各种文档格式自由转换
查看>>
Erlang基础Mnesia 之应用场景(Why)
查看>>