poj 2349 Arctic Network 【最小生成树-Kruskal】

【代码超详解】POJ 2349 Arctic Network(Kruskal 算法) 一、题目描述 阅读详情

Arctic Network
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 18709 Accepted: 5918

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

1
2 4
0 100
0 300
0 600
150 750

Sample Output

212.13

AC:

#include<stdio.h>  
#include<math.h>  
#include<algorithm>  
using namespace std;  
int father[550], m, k;  
double d[550];  
struct post  
{  
    double x, y;  
}p[550];  
struct edge  
{  
    int u, v;  
    double w;  
}e[500005];  
bool comp(edge e1, edge e2)  
{  
    return  e1.w < e2.w;  
}  
double get_dis(double x1, double y1, double x2, double y2)  
{  
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));  
}  
void Init(int n)  
{  
    for(int i = 1; i <= n; i++)  
        father[i] = i;  
}  
int Find(int x)  
{  
    if(x != father[x])  
        father[x] = Find(father[x]);  
    return father[x];  
}  
void Merge(int a, int b)  
{  
    int p = Find(a);  
    int q = Find(b);  
    if(p > q)  
        father[p] = q;  
    else  
        father[q] = p;  
}  
void Kruskal(int n)  
{  
    k = 0;  
    double Max = 0;  
    for(int i = 0; i < m; i++)  
        if(Find(e[i].u) != Find(e[i].v))  
        {  
            Merge(e[i].u, e[i].v);  
            d[k++] = e[i].w;  
            n--;  
            if(n == 1) //当所有顶点都遍历完时,退出该函数
                return;  
        }  
}  
int main()  
{  
    int t, S, P, i, j;  
    double x, y;  
    scanf("%d",&t);  
    while(t--)  
    {  
        m = 0;  
        scanf("%d%d",&S,&P);  
        Init(P);  
        for(i = 1; i <= P; i++)  
            scanf("%lf%lf",&p[i].x, &p[i].y);  
        for(i = 1; i <= P; i++)  
            for(j = i + 1; j <= P; j++)  
            {  
                e[m].u = i;  
                e[m].v = j;  
                e[m++].w = get_dis(p[i].x, p[i].y, p[j].x, p[j].y);  
                e[m].u = j;  
                e[m].v = i;  
                e[m++].w = get_dis(p[i].x, p[i].y, p[j].x, p[j].y);  
            }  
        sort(e, e+m, comp);  //以边上的权值大小进行排序
        Kruskal(P);  
        printf("%.2lf\n",d[P-S-1]);  
    }  
    return 0;  
}  


电动汽车充电标准之 — IEC 61851 “电动汽车传导充电系统”简介 IEC 61851 作为电动汽车传导充电系统的核心国际标准,从通用要求、安全规范、EMC性能到具体的测试方法,为全球电动汽车充电设施的安全、可靠和互联互通提供了关键技术依据。对于制造商而言,它是产品走向全球市场的通行证;对于消费者和运营商而言,它是安全高效充电体验的基石。希望以上信息能帮助你全面了解 IEC 61851 标准。如果你对某个具体的部分(例如某种充电模式、EMC 要求或者是直流充电通信协议的细节)特别感兴趣,我可以提供更进一步的说明。 阅读详情

相关推荐

电商产品组合策略:引流品与利润品的实战方法论

在电商运营中,产品组合策略是提升流量转化与利润增长的核心技术。其基本原理是通过数据化选品构建产品矩阵,利用引流品吸引用户流量,再通过利润品实现商业变现。这种策略不仅能优化广告投放的ROAS(广告投入产出比),还能显著提升客单价。技术实现上需要结合Google Analytics等工具进行归因分析,并运用动态库存管理模型控制风险。该方案特别适用于Amazon、Shopify等电商平台,能有效解决跨境电商业内流量获取与利润创造的平衡难题。通过实战案例可见,合理的产品组合可使客单价提升30-50%,是电商运营必备

weixin_42522009的博客 372

POJ 2349 Arctic Network

2016.12.30【题目简述】 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

Forever_MZY 364

Dify 部署与使用

本文介绍了Dify社区版的快速部署指南,涵盖系统架构、环境配置和初始化流程。Dify采用微服务架构,通过Docker Compose一键部署8个核心容器,包括前端、后端、数据库等组件。部署过程包括克隆代码、配置环境变量和启动服务,首次启动需3-10分钟下载镜像。文章详细讲解了.env文件的配置要点,包括服务地址、数据库连接和向量存储设置,并提供了生产环境安全加固建议。最后通过访问/install页面完成管理员账号初始化,即可开始使用Dify构建AI应用。

海兰 606

POJ 2349 Arctic Network——最小生成树

问题来源Arctic Network。 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...

anlian523的博客 388

绝缘检测是什么? 绝缘检测原理 绝缘检测检测的是什么?那个量?电压?电流?电阻?

绝缘电阻是电气设备和电气线路最基本的绝缘指标。对于低压电气装置的交接试验,常温下电动机、配电设备和配电线路的绝缘电阻不应低于0.5MΩ(对于运行中的设备和线路,绝缘电阻不应低于1MΩ/kV)。 绝缘电阻的正确测量方法 现代生活日新月异,人们一刻也离不开电。在用电过程中就存在着用电安全问题,在电器设备中,例如电机、电缆、家用电器等。 影响因素 环境温湿度 一般材料的绝缘电阻值随环境温湿度的升高而减小。相对而言,表面电阻(率)对环境湿度比较敏感,而体电阻(率)则对温度较为敏感。 湿度增加,表面泄漏增大,导体电导

dianqicyuyan的博客 2万+

单元测试工具TOP10对比:哪款最适合你的项目?

揭晓单元测试工具TOP10

2501_92667898的博客 1333

POJ-2349题解

POJ-2349 题目描述The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies ar...

cpongo11的博客 518

HDRP shader 获取阴影(Custom Pass)

Unity:2021.3.0f1 HDRP:12.1.6

LanQ的博客 2105

算法题 最小生成树-06-Arctic Network

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 o...

weixin_43813718的博客 235

Basler相机和pylon viewer 的使用

文章目录1 线路连接2 安装和使用pylon 1 线路连接 电源线接到电源插座,网线接到电脑(电脑没有网口的话,可用转换器转到type-c接口)。 2 安装和使用pylon 参考 Basler pylon安装及对网口相机基本设置 相机和电脑以太网IP设置参考:balser相机IP设置 关于相机参数和pylon viewer的详细设置,可以参考pylon Viewer安装路径下的文档(Documentation) ...

Deephome的博客 1万+

[后端设计]innovus命令editPin详解?

先放命令,有空慢慢写。

m0_61003348的博客 5760

POJ - 2349 Arctic Network 最小生成树

GDUT 2020寒假训练 图论 E 原题链接 POJ - 2349 Arctic Network E - Arctic Network 题目 Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two ...

xcy2001的博客 345

33、嵌入式系统中的内存操作与实时操作系统

本博客详细探讨了嵌入式系统中的内存操作和实时操作系统(RTOS)的基本原理及应用。内容涵盖C、C++和MicroPython三种语言下的SDRAM读写示例,并结合机器人真空吸尘器的实际应用说明内存的使用场景。此外,还介绍了RTOS的核心概念、组件及其工作机制,包括任务、事件、互斥锁、信号量、队列等,并以FreeRTOS和Mbed OS为例展示了RTOS的配置与使用方法。最后,通过常见问题和实践项目加深对嵌入式系统开发的理解。

zz67890的博客 149

POJ2349Arctic Network之最小生成树kruskal解法

Arctic Network Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 23142 Accepted: 7110 DescriptionThe Department of National Defence (DND) wishes to connect several northern outp

天行健,君子以自强不息 387

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

poj2349 Arctic Network 最小生成树,kruskal

题目链接:http://poj.org/problem?id=2349 题目

basement_boy 750

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

POJ2349 Arctic Network 题解【最小生成树】【Kruskal】【图论】

POJ 2349

中国计算机学会成都七中(高新校区)委员会委员活动室 393

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

poj 2349 Arctic Network 最小生成树 kruskal

题目链接                 https://cn.vjudge.net/contest/245639#problem/D 题目大意                将n个顶点连接起来, 使得边的权值之和最小,  而题目要输出的不是最小权值和, 而是在最小生成树上找出一条权值最大               的边, 输出这条边的权值 ,当然是有前提的, 要先除去s-1条最大的边,...

looeyWei的博客 247

POJ - 2349 Arctic Network (最小生成树 Kruskal)

Arctic Network 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 t...

YOONGI 243

POJ 2349 Arctic Network+Kruskal最小生成树

Arctic Network Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18714   Accepted: 5921 Description The Department of National Defence (DND) wishes to connect

fans_ac的博客 348

POJ - 2349Arctic Network最小生成树kruskal

贴模板 有卫星的两个点之间随意通信。没有卫星的点之间距离不超过D可以通信。求最小D。 没有卫星的情况下,用kruskal建一课最小生成树时,会对边进行排序。这时边的最大值就是答案。有卫星的情况下,让距离最大的点拥有卫星,s个卫星使用了s-1个边。第 总边数减去s-1 个边就是要求的最小D。#include <stdio.h> #include <string.h> #include <iostr

dreambyday 395

Arctic Network(POJ 2349)(最小生成树Kruskal)

Arctic Network(POJ 2349)(最小生成树Kruskal)

Ema1997的博客 583

POJ2349 Arctic Network(最小生成树,Kruskal)

题目: Arctic Network Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18625   Accepted: 5892 Description The Department of National Defence (DND) w

riba2534的博客 518

poj 2349 Arctic Network 最小生成树第k大边-kruskal

#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <string> #include <math.h> #in

禅境花园 398

Arctic Network POJ - 2349 (最小生成树Kruskal)

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 ou

退役的铜牌狗 335

最小生成树 (Kruskal算法)POJ 2349 Arctic Network

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 net...

qq_40859951的博客 244

POJ 2349 Arctic Network (最小生成树Kruskal)

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 ...

weixin_33901843的博客 105
上一篇: poj 3026 Borg Maze 【prim+bfs】
下一篇: poj 1679 The Unique MST【次小生成树】【判断最小生成树的唯一性】
風穆
博客等级 码龄10年 12粉丝 123原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值