hdoj2680 Choose the best route(dijstra)

联想拯救者恢复出厂设置全攻略 通过本文介绍的几种方法,你可以轻松地将联想拯救者恢复到出厂系统状态。无论是通过Windows恢复选项、高级启动选项还是一键恢复功能,都能帮助你解决系统问题、清除个人信息或重置软件环境。在重置前,请务必备份重要数据,并确保了解重置的影响。重置完成后,进行适当的系统设置和软件安装,让你的联想拯救者焕然一新,继续为你提供高效、稳定的计算体验。 阅读详情

Choose the best route

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 10670    Accepted Submission(s): 3443


Problem Description
One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kiki’s home so that she can take. You may suppose Kiki can change the bus at any station. Please find out the least time Kiki needs to spend. To make it easy, if the city have n bus stations ,the stations will been expressed as an integer 1,2,3…n.
 

Input
There are several test cases. 
Each case begins with three integers n, m and s,(n<1000,m<20000,1=<s<=n) n stands for the number of bus stations in this city and m stands for the number of directed ways between bus stations .(Maybe there are several ways between two bus stations .) s stands for the bus station that near Kiki’s friend’s home.
Then follow m lines ,each line contains three integers p , q , t (0<t<=1000). means from station p to station q there is a way and it will costs t minutes .
Then a line with an integer w(0<w<n), means the number of stations Kiki can take at the beginning. Then follows w integers stands for these stations.
 

Output
The output contains one line for each data set : the least time Kiki needs to spend ,if it’s impossible to find such a route ,just output “-1”.
 

Sample Input
5 8 5 1 2 2 1 5 3 1 3 4 2 4 7 2 5 6 2 3 5 3 5 1 4 5 1 2 2 3 4 3 4 1 2 3 1 3 4 2 3 2 1 1
 

Sample Output
1 -1
</pre><pre name="code" class="cpp">
</pre><pre name="code" class="cpp">
<pre name="code" class="cpp">#include<stdio.h>
#define INF 0x6ffffff
#include<string.h>
#include<algorithm>
using namespace std;
int cost[1101][1101];
int dis[1101];
int used[1101];
int n;
void dij(int s)
{
	int i;
for( i=1;i<=n;i++)
{
	dis[i]=INF;
	used[i]=false;
}
	dis[s]=0;
	while(true)
	{
		int v=-1;
		for( i=1;i<=n;i++)
		{
			if(used[i]==0&&(v==-1||dis[v]>dis[i]))
			v=i;
		}
		if(v==-1)
		break;
		used[v]=true;
		for(i=1;i<=n;i++)
		dis[i]=min(dis[i],dis[v]+cost[v][i]);
	}
}

int main()
{
	int m,s,a,b,c,i,j,x,t;
	while(~scanf("%d%d%d",&n,&m,&s))
	{
		memset(dis,0,sizeof(0));
		for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			if(i==j)
			cost[i][j]=0;//相同车站距离为0 
			else
			cost[i][j]=INF;
		}
		for(i=0;i<m;i++)
		{
			scanf("%d%d%d",&a,&b,&c);
			if(cost[b][a]>c)//防止重边 
			cost[b][a]=c;
		}
		scanf("%d",&t);//有几个起点  
		int min=INF;
		dij(s);//由于终点只有一个可以看作起点 
		for(i=0;i<t;i++)
		{
		scanf("%d",&x);
		if(dis[x]<=min)//求出距离最小值 
		min=dis[x];
		}
		if(min!=INF)//如果都是INF则输出-1 
		printf("%d\n",min);
		else
		printf("-1\n");
		}
		return 0;
}



R语言基于机器学习三分类结果、计算三分类混淆矩阵、计算每一个类别对应的特异度(specificity)、灵敏度(sensitivity)、PPV、NPV 阅读详情

相关推荐

通义灵码+高德 MCP:40分钟开发出游攻略网站

本文介绍了通义灵码与高德MCP在40分钟内快速开发出游攻略网站的全流程。主要内容包括:1)LingmaIDE开发环境的使用方法,涵盖界面操作、代码编辑、调试和智能编码功能;2)通义灵码智能体与高德MCP2.0的集成步骤,通过输入旅行需求即可自动生成包含天气卡片、景点路线等元素的HTML页面;3)重点展示了如何将行程规划导入高德地图APP,实现导航、打车等出行功能。整个开发过程充分利用了通义灵码的智能编码能力和高德地图的服务接口,显著提升了旅游类应用的开发效率。

soso1968的博客 986

Choose the best route (最短路径,多起点)

One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and t...

weixin_44584292的博客 777

CodeBuddy 接入 MCP,一键生成网站!

2024 年 11 月,Anthropic 公司搞了个挺有意思的新玩意 - Model Context Protocol(模型上下文协议)简称为 MCP 协议。简单来说,它就是给 AI 和各类工具数据之间搭了个标准化的”桥梁”,让开发者不用再为对接问题头疼了。mcp.so如下图所示,这是 mcp.so 网站中的 MCP Server。使用百度/高德地图分析旅线计算时间接 Puppeteer 自动操作网页使用 Github/Gitlab 让大模型接管代码仓库。

悟空聊架构的专栏 1946

Choose the best route

Problem Description One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city

吃葡萄不吐葡萄皮 1220

【腾讯小龙虾WorkBuddy专栏04】一文搞懂WorkBuddy的「专家」和「专家团」

WorkBuddy专家与专家团:专业级AI协作解决方案 WorkBuddy的专家(Expert)与专家团(Expert Team)功能颠覆了通用AI的局限性,提供角色化、可交付的专业服务。 核心优势 专家:深度垂直领域的AI顾问,具备人设、方法论、工具链,如全栈开发专家能直接交付完整项目,而非代码片段。 专家团:多智能体协作,自动拆解复杂任务(如竞品分析、全栈开发)并分发给对应角色,并行执行后整合输出,效率提升显著。 使用场景 单专家:解决专业问题(如SQL优化、UI设计)。

AI人人懂 2028

【车载以太网】【SOMEIP】Wireshark测试someip

一、 Wireshark SOMEIP plugin 1.1 插件安装 Wireshark插件目录:Help -> About Wireshark -> Folders/Pluginshttps://github.com/jamores/eth-ws-someip 解压后,将所有后缀是lua的文件拷贝到Wireshark安装目录plugins/2.4.10/下。 1.2时间戳调整为UTC显示格式 View -> Time Display Format -> Date and Tim.

专注汽车软件开发、AutoSAR、车载以太网、SOA、EE架构。 9726

杭电2680——Choose the best route(Dijkstra)

Choose the best route(选择最佳路线) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=2680 Problem Description One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give

abcdefghikk的博客 469

vLLM显存逆向计算:如何得到最优gpu-memory-utilization参数

本文提出了一种**逆向工程**的思路:基于vLLM显存占用的底层机制,通过精确计算模型权重、KV缓存、激活内存等各组件的显存需求,**倒推出最优的gpu-memory-utilization参数**。这种方法让我们能够在部署前就准确预估资源需求,实现一次配置、稳定运行。本文我们将从vLLM显存计算的核心原理出发,构建完整的倒推计算框架和源码,并通过大量实验验证其准确性(会有误差,但基本可以直接使用)。

羊城迷鹿的博客 1949

Choose the best route 【最短路】+【反向建图】

One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and th

lzs_lazy 422

RK3568适配MIPI屏幕触摸,触摸延时很大

我用的是系统,接了一个,设备树已经正确配置,evtest测试坐标值和触摸位置都是准确的。但是出现了一个:我在屏幕上点一下,要等大约 2 秒才能在evtest里看到坐标事件打印。这种现象在 Goodix 系列触摸驱动里比较少见,一般意味着。

小灰灰的博客 1363

基于双向GRU LSTM DNN水电站水文数据的每日径流量预测 完整代码+数据 可直接运行

基于双向GRU LSTM DNN水电站水文数据的每日径流量预测 完整代码+数据 可直接运行

1902

HDOJ 2680 Choose the best route (Dijstra 多个起点)

点击打开链接 同样是乘公交车,这道题就变成了有向图- -。特点就是有多个起点,比较简单的处理方法是加一个点0,把它作为新的起点,与原来的起点之间路径为0。这么一改动以后要注意后面最外层循环要多循环一次了(看程序中的标注)。如果有多个终点也是同理处理。 #include #include const int INF = 0x3f3f3f3f; const int VN =

Muya 288

YOLOv8安防监控实战:跌倒/闯入/徘徊实时检测(附TensorRT加速+声光报警部署代码)

精准性:针对跌倒/闯入/徘徊的行为特征优化,准确率达89.3%,误报率低于5次/天;实时性:TensorRT加速到50+FPS,报警延迟<1秒,满足安防“黄金响应时间”;低成本:无需专用AI芯片,RTX 3060或Jetson Orin就能跑,硬件成本比传统方案低60%;易部署:代码全开源,提供从模型训练到硬件联动的完整流程,2天即可搭起原型系统。如果你的安防监控还在“漏报误报”“响应慢”,建议先从跌倒检测的姿态过滤改起——用100张样本测试,再集成TensorRT加速,90%能看到明显改善。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 681

Choose the best route(Dijkstra)

Choose the best route(Dijkstra) 原题:hdu2680 这是一道有点难度的最短路径题,要想到以最后终点为起点进行搜索,或者新建一个起点用0表示,题目给的起点与0点连接且距离为零,其他点不与0点相连接,进行搜索。我一开始用Floyd来解,发现后来怎么优化都超时,看来这种单源点题目还是要用Dijkstra来解。 代码如下: #include &lt;iostream&gt...

qq_34851605的博客 307

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

[24] Choose the best route

dijkstra(hduoj)

syj2347的博客 469

WINCC7.3破解文件

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

【2680】Choose the best route

2680 dijkstra算法,参考了网上创建一个虚拟0结点的做法,规避了多个起点带来的困难,也优化了以终点作为起点然后再翻转的方法。只需要这样算一次就好了。 #include<bits/stdc++.h> using namespace std; const int MAX=0xfffffff; int mep[1010][1010]; int vis[1010],dis[1010]; int main(){ int n,m,s; int p,q,t; int w,start; whi

weixin_49646622的博客 127

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Choose the best route ( dijkstra 路径翻转 )

Choose the best route One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kiki’s

是微风,是晚霞,是无可替代 329

Choose the best route (最短路)

One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and t

月殇 788

Choose the best route 2680 (dijkstra,反向建图)

Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10282    Accepted Submission(s): 3317 Problem Description One day

yanghui07216的博客 395

HDU 2680 Choose the best route(最短路,反向)

HDU临时网站:http://acm.split.hdu.edu.cn/showproblem.php?pid=2680 Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 132

Shyazhut 420

HDU 2680 Choose the best route 多源点+一汇点求最短路

点击打开链接   Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5639    Accepted Submission(s): 1811 Problem Descript

代码改变世界,keep coding。 1095

杭电2680-Choose the best route(最短路反向建图)

Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10891    Accepted Submission(s): 3529 Problem Description O

Eric_keke的专栏 734

hdu-2680Choose the best route (dijkstra求最短路)

Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10601    Accepted Submission(s): 3415 Problem Description One day

bokzmm的博客 431

hdu Choose the best route(最短路 --- Dijkstra)

Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4040    Accepted Submission(s): 1260 Problem Description One

勿忘初衷 2494

Hdu-2680 Choose the best route

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2680 题目大意: 给你一个有向图,一个起点集合,一个终点,求最短路。。。。 解题思路: 1.自己多加一个超级源点,把起点集合连接到超级源点上,然后将起点与超级源点的集合的路径长度设为0,这样就称为一个n+1个点的单源最短路算法。。。。。 2.反向图+终点的Dijkstra

编程中快乐 618

hdu2680

Choose the best route Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1788    Acc

ACM 703
上一篇: hdoj1536 find the safest road(dijstra)
下一篇: nyoj77开灯问题 VS poj1218 THE DRUNK JAILER(开关灯问题模板)
JINKELA_
博客等级 码龄11年 75粉丝 178原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值