[poj2349 Arctic Network]最小生成树

【随机过程】第二章——随机过程概论 随机过程概论,说明《随机过程》课程的教学大纲,对随机过程概念、研究对象和研究方法做了简要介绍。 阅读详情
Arctic Network
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 10805 Accepted: 3542

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

Source

Waterloo local 2002.09.28
Kruskal搞的最小生成树。
Memory: 2676K Time: 110MS
Language: G++ Result: Accepted
/*
	初始化每个点一个连通分量 
	每次只需要选最小边即可,然后在剩下s个连通分量时答案就更新完毕鸟
*/ 
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;

const double INF = 1e10;
const int MAX = 512;
struct Point {
	double x, y;
	double dis(const Point& B) {
		return sqrt((x - B.x) * (x - B.x) + (y - B.y ) * (y - B.y));
	}
} a[MAX];
struct edge {
	int from, to;
	double cost;
};
struct cmp {
	bool operator()(edge& e1, edge& e2) {
		return e1.cost > e2.cost;
	}
};

int father[MAX];

int find(int x) {
	return x == father[x] ? x : father[x] = find(father[x]);
}
void Union(int x, int y) {
	int fx = find(x), fy = find(y);
	if (fx != fy) {
		father[fx] = fy;
	}
}

double gao(int s, int p) {
	priority_queue<edge, vector<edge>, cmp> Q;
	for (int i = 0; i < p; ++i) {
		for (int j = i + 1; j < p; ++j) {
			Q.push((struct edge){i, j, a[i].dis(a[j])});
		}
		father[i] = i;
	}
	double ans = 0.0;
	for (int i = s; i < p; ++i) {
		edge e;
		e.from = e.to = e.cost = 0.0;
		while (!Q.empty()) {
			e = Q.top();
			Q.pop();
			if (find(e.from) != find(e.to)) break;
		}
		
		Union(e.from, e.to);
		if (ans < e.cost) ans = e.cost;
	}
	return ans;
}

int main() {
	int T;
	scanf(" %d", &T);
	while (T--) {
		int s, p;
		scanf(" %d %d", &s, &p);
		for (int i = 0; i < p; ++i) {
			scanf(" %lf %lf", &a[i].x, &a[i].y);
		}
		printf("%.2f\n", gao(s, p));
	}
	return 0;
}


ConvNeXt 系列改进:二次创新 ConvNeXt:结合 RepVGG 结构重参数化,训练多分支、推理单路 2026年的视觉模型赛道呈现出一种有趣的“返璞归真”趋势——在Transformer狂飙数年之后,卷积网络正以全新的姿态回归。这其中,ConvNeXt无疑是纯卷积阵营中最耀眼的明星。从2022年Meta AI首次提出至今,ConvNeXt系列已经走过了近四年的演进之路,衍生出ConvNeXt V2、E-ConvNeXt等多个增强版本。ConvNeXt的7×7深度卷积带来了不错的感受野,却也埋下了推理效率的隐患。 阅读详情

相关推荐

【NAS系统】DSM7.2部署SVN服务

早期的群晖版本可以在套件中心找到SVN Server直接安装,然后配置仓库和用户。但‌2提到DSM7.0之后套件中心没有SVN了,得用Docker。

qq_38350004的博客 4847

最短路问题-最小生成树-通信问题

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 w

weixin_46204099的博客 422

vivado生成及调用自定义IP的方法

开发环境:vivado 2018.2 1.将整个工程封装为自定义IP 将整个工程封装为自定义IP主要有以下步骤: 步骤1.选中工程中的top模块。点击Tools ------> Create and Package New IP,如图1所示 图1 步骤2.弹出界面后,点击next至图2界面,选择Package your current project,然后继续点击next 图2 步骤3.选择生成的IP路径,如图3所示。这个路径就是后续添加该IP的路径 图3 步骤4.继续点击next,然后选择fi

进击的阿日比 4728

【POJ 2349 --- Arctic Network】prim || kruskal

【POJ 2349 --- Arctic Network】prim || kruskal 题目来源:点击进入【POJ 2349 — Arctic Network】 Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network...

来日浅谈的博客 542

FeynRules的上手使用3--运行

FeynRules的运行 接上两篇,在我们正确的设定模型参数和拉氏量之后,就可以运行FeynRules来推导费曼规则。 装载文件 首先需要设定FeynRules文件所在位置,并装载FeynRules模块: $FeynRulesPath = SetDirectory[ ] << FeynRules` 接下来是装载写好的模型文件: LoadModel[ < file.fr >, < file2.fr >, … ] 模型文件后缀为".fr",可以分几块构成。模型描述可以写在

cool_bot的博客 1074

SAP PP模块MRP控制参数实战指南:从NETCH到NEUPL的深度解析

本文深入解析SAP PP模块中MRP控制参数的配置与应用,涵盖NETCH、NETPL和NEUPL三种运行模式的优化策略。通过实战案例和参数对比,帮助用户提升物料需求计划的效率和准确性,优化库存周转率和生产交付能力。

weixin_28419039的博客 244

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

TruckSim与Simulink联合仿真中的车轮转角精确控制策略

本文深入探讨了TruckSim与Simulink联合仿真中实现车轮转角精确控制的关键策略。针对多轴车辆路径跟踪时转角指令失灵的常见问题,核心在于正确配置TruckSim转向轴的外部输入模式(Advanced Settings),并确保仿真接口的稳定搭建。文章详细解析了从单轴到多轴协同转向的配置方法,并提供了提升MPC路径跟踪精度的实战技巧与调试经验。

weixin_29035147的博客 367

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

D19: OpenClaw 安全性配置指南

在 OpenClaw 的 30 天探索旅程中,我们已经探讨了邮件自动化(D18)。今天进入安全专题,我将分享一个至关重要的话题:OpenClaw 安全性配置指南。 随着 OpenClaw 深入工作流核心,它掌握了越来越多的敏感信息: API Keys(GitHub、飞书、Notion、Jira...) 企业数据(代码库、文档、聊天记录) 个人数据(日历、邮件、任务) 系统权限(文件读写、命令执行、网络访问) 安全不是可选项,而是必选项。一次配置失误可能导致: API Key 泄露 → 账号被盗用权限

刘一说的IT专栏 203

【Kubernetes】Kubernetes 安全沙箱深度对比:gVisor vs Kata Containers

Kubernetes安全沙箱深度对比:gVisor和Kata Containers在架构、性能与安全性方面各有特点。gVisor通过用户态内核(Sentry)实现软件隔离,启动快(毫秒级)但CPU开销大(20-30%),适合Web服务等场景。Kata Containers采用轻量级虚拟机提供硬件级隔离,启动较慢(1-2秒)但兼容性更好,适合金融等高安全需求。测试显示gVisor在动态请求下性能下降33%,而Kata性能接近原生。建议根据场景选择:多租户/快速启动用gVisor,敏感数据/极致安全用Kata,

九师兄 178

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

55、磁吸附爬壁机器人运动仿真与位置控制

本文针对大型船舶喷涂作业中人工操作存在的高风险与低效率问题,提出一种基于麦克纳姆轮的磁吸附爬壁机器人运动控制方案。通过建立Adams虚拟样机与MATLAB/Simulink控制系统的联合仿真模型,设计了速度和位置双闭环控制系统,采用模糊PI控制器优化速度响应,并引入位置反馈补偿重力引起的垂直偏移。研究结果表明,模糊PI控制器在响应速度、超调抑制和位置稳定性方面优于传统PI控制器,且位置反馈能有效校正横向移动中的下坠现象,尤其在跨越焊缝等复杂工况下仍可保持稳定运行,显著提升了爬壁机器人的运动精度与作业可靠性。

linux6sysadmin的博客 168

poj2349 Arctic Network 最小生成树

poj2349 表示刚开始读题就读了n久没有读明白。。。明白了题意以后这题真真是个套模板的题 题意:哨站有两种通信方式:通过卫星和通过建立无线网络,通过卫星可以任意通信, 通过无线网络那么距离不能超过D,求这个最小距离D。 思路:s代表了可以扔掉s-1条边,p表示点 我采用了kruskal算法,在建立好的最小生成树中去掉s-1条边,那么返回上一个的权值w即可。 #include #in

竹丙丙丙丙 404

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

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

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

(最小生成树)POJ2349Arctic Network

POJ2349Arctic Network 题意&思路: 给你p个点和s-1条免费边,问使两两点连通的最小的最长边。 求第p-s条最长边,kruskal。用%lf记得交c++。 代码: #include<iostream> #include<stdio.h> #include<stdlib.h> #include<algorithm> #in...

Z7784562的博客 293

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

POJ 2349 Arctic Network (最小生成树)

POJ 2349 Arctic Network (最小生成树)

一枚空指针的博客 383

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Arctic Network/POJ 2349/最小生成树

Arctic Network/POJ 2349/最小生成树 题目 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 ...

weixin_45600829的博客 146

POJ2349 Arctic Network 最小生成树

链接: 2349 题意:一个平面网络中 有M个卫星N个站点,每两个站点之间可以用通讯器联系或用卫星联系,用通讯器联系的花销和距离有关,用卫星联系则不需要花销。给出每个站点的坐标(x,y),求这个网络最小生成树的最大边。 题解: M个卫星一共可以减去M-1条边,通过prim算法求出生成树中的所有(n-1)条边,通过排序,再减去(m-1)

旧时光 1007

POJ 2349 Arctic Network 最小生成树

POJ 2349 Arctic Network 最小生成树 Kruskal

LucienShui 640

POJ 2349 Arctic Network 最小生成树题解

本题也是使用Prime和Kruskal都可以的最小生成树的题解。 本题一点新意就是:需要除去最大的S-1个距离,因为可以使用卫星覆盖这些距离。 技巧:建图建有向图,速度快点,不用计算两边。 这里使用Prime,因为是稠密图。 #include #include #include #include #include #include using std::sort; c

靖空间 1378

POJ 2349 Arctic Network(进阶指南,最小生成树)

算法竞赛进阶指南,454页,最小生成树,kruskal 题目意思: 有n个 北部前哨站, 每个站都可以用无线电收发器来通信,也可以用卫星电话通信; 卫星电话不受距离影响,但数量少,只有s个。无线电收发器每一个前哨站都有,受距离影响, 距离D越远,成本越高。无线电通信距离D都是相同的。 题目要求,使得n个前哨站能直接或间接通信, 成本最少,也就是无线电收发器的通信距离D最短。 本题要点: 1、 有 s个卫星,那么最小生成树就可以少 s - 1 条边。 原来树有 n点,n - 1 条边, 减去 s - 1 条,

qq_38232157的博客 177

POJ 2349 Arctic Network 最小生成树 prim && kruscal

Arctic Network 克鲁斯卡尔(kruscal)或普里姆算法(Prim) 求最小生成树。 Arctic Network Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13208 Accepted: 4284 Description The Department of National Defence (DND) wishes to connect several northern outposts by a w

jianjun的专栏 637

POJ 2349-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: e...

include_peng的博客 331

POJ 2349 Arctic Network(最小生成树思想)

POJ 2349 Arctic Network(最小生成树思想) http://poj.org/problem?id=2349 题意: 题意有点坑…        有P个站点需要远程通信,它们能通过两种方式来通信:无线电和卫星. 如果两个站点通过两个卫星接收器(坑,每个站点各一个卫星接收器)来通信的话,它们直接无论多远都行且不花钱. 如果两个站点通过无线电来通信的话,需要花钱且距离越长花费越

code 1288

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的博客 344

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 n

Kelisiya 395
上一篇: [poj1144 Network]tarjan求割点
下一篇: [poj1258 Agri-Net]最小生成树
bit_line
博客等级 码龄12年 33粉丝 150原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值