#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>
#include <stdlib.h>
using namespace std;
const double inf=100000000;
double ans,mp[105][105],x[105],y[105],lowcost[105];
int main()
{
int i,j,k,n,pn,pa;
while(~scanf("%d",&n))
{
if(n==0) break;
scanf("%d%d",&pn,&pa);
for(i=1;i<=n;i++)
scanf("%lf%lf",&x[i],&y[i]);
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
mp[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
ans=mp[pn][pa];
mp[pn][pa]=0;
mp[pa][pn]=0;
for(i=1;i<=n;i++)
lowcost[i]=mp[1][i];
lowcost[1]=-1;
for(i=1;i<=n;i++)
{
int v=-1;
double minx=inf;
for(j=1;j<=n;j++)
{
if(lowcost[j]!=-1&&minx>lowcost[j])
{
minx=lowcost[j];
v=j;
}
}
if(v!=-1)
{
ans+=minx;
lowcost[v]=-1;
for(j=1;j<=n;j++)
{
if(mp[v][j]<lowcost[j])
lowcost[j]=mp[v][j];
}
}
}
printf("%.2lf\n",ans);
}
return 0;
}
相关推荐
Spring AI Alibaba Skill 实战:定义、注册与渐进式披露的企业级落地
摘要:很多团队在接入大模型时,第一步做到的是“能对话”,第二步遇到的瓶颈却是“不能可靠执行”。Skill 的本质不是给模型多几个函数,而是把企业系统中的可控能力,以可治理、可审计、可扩展的方式交给 Agent。本文围绕 Spring AI Alibaba Skill 的定义、注册与渐进式披露,结合电商客服与售后场景,系统讲清楚其底层原理、架构设计、生产级实现、高并发治理与工程实践。@Component@Tool(description = "根据订单号查询订单状态、支付状态和物流状态")扫描包含。
HDU-4463-Outlets
HDU-4463-Outlets http://acm.hdu.edu.cn/showproblem.php?pid=4463 已知两点相连,求最小生成树,第一次参加现场赛,各种悲剧。。。这题我敲的,调试了半天才过。。。菜鸟伤不起哇。。。 #include #include #include #include #define N 100 struct node { int x; int
从零开始:Vivado中自定义串口通信IP核的完整实现
本文详细介绍了在Vivado中从零开始实现自定义串口通信IP核的完整流程,包括Verilog核心代码编写、仿真验证、IP核封装与参数化配置技巧。通过AXI-Lite总线实现动态配置,提升FPGA开发效率,适用于各种嵌入式系统通信需求。
HDU 4463 最小生成树 并查集
#include #include #include using namespace std; const int maxn=55; struct point { int x,y; }pnt[maxn]; struct edge { int s,e; double len; bool operator < (edge e) const {
使用Tansformer分割三维腹部多器官--UNETR实战
不会 transformer 没关系,本教程开箱即用。Tina姐总算对transformer下手了,之前觉得难,因为刚开始学序列模型的时候就没学会。然后就一直排斥学transformer。这两周没什么事,加上MONAI有现成的教程,就打算先跑通后,再学理论。然后,顺利的跑通了代码,再学了一周理论,发现它也不过如此嘛,入门还是很容易的。有同学想了解的transformer的话,可以先看完这个实战教程,如果感兴趣,后续会出一个transformer入门路线。利用纯Transformers作为编码器来学习输入量的
Unity UGUI深度优化
Unity UGUI优化相关
HDU1301 Outlets 解题报告--prim
Outlets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1053 Accepted Submission(s): 475 Problem Description In China, foreign brand
【异常】OpenClaw认证 Please carry the API secret key in the ‘Authorization‘ field of the request header
OpenClaw助手Agent因401认证异常导致业务中断的排查方案。该异常由大模型API鉴权全量失败触发,主要根因包括API凭证配置错误、密钥过期、账号权限不足或请求格式不规范。解决方案分四级:优先校验并修正API密钥;排查账号状态与调用权限;检查请求格式规范;最后排查网络或服务商问题。建议建立密钥生命周期管理机制,定期监控额度,使用专用API密钥以规避类似问题。该异常属于凭证配置类故障,不影响系统稳定性。
hdu 4463(最小生成树变形)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4463思路:由于nike与apple必须有直接的边相连,因此可以先把这条边选进去,然后就是Kruskal求最小生成树了,由于一开始已经把点nike和点apple合并了,因此kruskal选择边的时候就不会选进去了。 1 #include<iostream> 2 #includ...
Unreal Engine Profiler:动画系统性能分析教程_2024-07-23_03-05-38.Tex
Unreal Engine Profiler 是一个内置的性能分析工具,它可以帮助开发者识别和解决游戏中的性能瓶颈。Profiler 提供了详细的性能数据,包括 CPU 使用率、GPU 负载、内存使用情况等,特别针对动画系统,可以查看动画蓝图的执行时间、骨骼动画的计算成本、以及动画混合和重定向的效率。通过这些数据,开发者可以定位到具体的问题,比如哪些动画状态消耗了过多的 CPU 时间,或者哪些动画资源导致了内存泄漏。
基于STM32设计的掌上游戏机(运行NES游戏模拟器)详细开发过程
利用STM32单片机移植NES游戏模拟器,完成NES游戏开发,可以玩标准的NES游戏,已测试超级玛丽、魂斗罗之类的都可以正常运行。
hdu 4463 Outlets(最小生成树)
题目链接:hdu 4463 Outlets 题目大意:给定N个点,以及P,Q,问说建立N-1条边联通N个点的最短长度,要求P,Q必须建立边。 解题思路:最小生成树水题。 #include #include #include #include #include using namespace std; const int maxn = 55; struct edge {
【NI Multisim 14.0原理图设计基础——元器件分类】
电阻(RESISTOR):该元器件栏中的电阻都是标称电阻,是根据真实电阻元器件而设计的,其电阻值不能改变。 排阻(RESISTOR PACK):相当于多个电阻并列封装在一个壳内,它们具有相同的阻值。 电位器(POTENTIOMETER):即可调电阻,可以通过键盘字母动态调节电阻,大写表示增加电阻值,小写表示减小电阻值,调节增量可以设置。 电容(CAPACITOR):所有电容都是无极性的,不能改变参数,没有考虑误差,也未考虑耐压大小。 电解电容器(CAP_ELECTROLIT):所有电容都是有极性的,“+”极
HDU 4463 Outlets(最小生成树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4463 题意:要在n个商店之间修路,商店p和q必须直接通过一条马路相连,所有商店之间必须能通过马路联系,求修建马路的最小长度。 分析:其实就是简单的求最小生成树问题,不过加了一个限制条件那就是点p q必须连接在一起,可在用并查集求最小生成树之前先将pq合并到一个子集中,然后在按部就班的求即可,最
IEM模型,地表粗糙度模拟
利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟
LinePhone3.2.7(android端最新版本) sip客户端
SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/
hdu4463 Outlets 最小生成树
不超过50个点,先给两个点s1,s2表示这两个点必须先连起来,接下来给出n个点的坐标,在先连接s1,s2的前提下求最小生成树。 N不到50..普利姆,克鲁斯卡尔随便都能搞吧..虽说完全图理论上普利姆快一点- -... #include #include #include #include #include #include #include #include #inclu
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
HDU 4463 Outlets (最小生成树kruskal算法)
Outlets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description In China, foreign brand commodities are often much more expensive than abroad. The main ...
Devexpress16.2.6破解工具
Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具
hdu 4463 Outlets(最小生成树,kruskal,前向星)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4463 最小生成树的应用,但是要先把其中两个点连接起来,然后选取剩余的n-2条边。为了和纯粹的kruskal算法尽量相似,我在结构体上多下了功夫,可能看起来有点复杂。 #include #include #include #include #include #include using names
HDU 4463 Outlets 【最小生成树】
<题目链接> 题目大意: 给你一些点的坐标,要求你将这些点全部连起来,但是必须要包含某一条特殊的边,问你连起这些点的总最短距离是多少。 解题分析: 因为一定要包含那条边,我们就记录下那条边的边权,然后将那条边边权置为0,再跑一遍最小生成树即可。 #include <cstdio> #include <cmath> #include <c...
HDU4463Outlets(最小生成树)
HDU4463Outlets(最小生成树) HDU4463Outlets 题目大意: 需要新建一个mall,里面有很多的商店,希望修最短的路,使得里面的店联通,可以通过别的店间接的联通,但是有规定两家店一定要直接的联通。求在这样的条件下的最短的路径。 解题思路: 最小生成树,只是前提是先要使得要求的两个结点先联通。 代码: #include #inclu
HDU 4463 Outlets 最小生成树Kr~
这个题貌似是12年杭州亚洲赛的题==,题意是求一个最小生成树,但是要求有两个已知点必须直接连着==其实挺水的,prim不好实现 改了一晚上。。。还是不知道自己最开始为啥错了=。= Description In China, foreign brand commodities are often much more expensive than abroad. The
HDU 4463 Outlets 最小生成树
题意:给出n个坐标,求出最短的路径使这n个点相连。其中有两个点必须连。
hdu 4463 Outlets【最小生成树】水题
Outlets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3476 Accepted Submission(s): 1609 Problem Description In China, foreign bran
hdu 4463 Outlets (最小生成树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4463 裸的最小生成树
HDU 4463 Outlets (Kruskal 最小生成树)
Outlets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1952 Accepted Submission(s): 897 Problem Description In China, foreign b
HDU-4463 Outlets 最小生成树
题意:就是最小生成树,题中给定了一条必须要连接的边,排序的时候不把他考虑进去即可。 代码如下: #include <cstdlib> #include <cstring> #include <cstdio> #include <algorithm> #include <iostream> #include <cma...
HDU-4463-Outlets -最小生成树
Outlets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1059 Accepted Submission(s): 481 Problem Description In China,foreign bran
637




被折叠的 条评论
为什么被折叠?



