1030 Travel Plan (30)

CAN 通信测试工具 canutils 概述 CAN,Controller Area Network,控制器局域网,一种高可靠性的现场总线。广泛用于汽车电子、工业控制通信。 canutils 工具包内含 5 个独立的程序:canconfig、candump、canecho、cansend、cansequence。这几个程序的功能简述如下: canconfig:用于配置 CAN 总线接口的参数,主要是波特率和模式。 candump... 阅读详情
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;


class CA
{
public:
enum{N=500,INF=0x7FFFFFFF/2};
//void init();
void run();
void getshortestlen();
void minimumcost(int c1,int cost);
private:
int n,m,sv,dv,mincost,ststlen;
int dist[N][N],cost[N][N];
int dx[N];
vector<int> path[N],tmppath,bestpath;
};






void CA::run()
{


cin>>n>>m>>sv>>dv;
fill_n((int*)dist,N*N,INF);
fill_n((int*)cost,N*N,INF);
int i,v1,v2,l,c;
for(i=0;i<m;i++)
{
cin>>v1>>v2>>l>>c;
dist[v1][v2]=dist[v2][v1]=l;
cost[v1][v2]=cost[v2][v1]=c;
}
   
mincost=INF;
getshortestlen();
minimumcost(dv,0);
//vector<int>::iterator it;
/*for(it=path[3].begin();it!=path[3].end();it++)
{
printf("%d ",*it);
}
printf("\n");*/
for(i=bestpath.size()-1;i>=0;i--)
{
printf("%d ",bestpath[i]);
}
printf("%d %d",ststlen,mincost);
}


void CA::getshortestlen()
{
bool visited[N];
int i,k;
for(i=0;i<n;i++)
visited[i]=false;
for(i=0;i<n;i++)
{
dx[i]=dist[sv][i];
//printf("%d \n",dx[i]);
}
//copy(dist[sv],dist[sv]+n,d);  
dx[sv]=0;
while(1)
{
k=-1;
for(i=0;i<n;i++)
{
if(visited[i])
continue;
if(k==-1||dx[i]<dx[k])
k=i;
}
if(k==-1)
{
break;
}
if(k==dv)
{
ststlen=dx[k];
break;
}
visited[k]=true;
for(i=0;i<n;i++)
{
if(visited[i])
continue;
if(dx[i]>dx[k]+dist[i][k])
{
path[i].clear();
dx[i]=dx[k]+dist[i][k];
path[i].push_back(k);
}
else if(dx[i]==dx[k]+dist[i][k])
{
path[i].push_back(k);
}
}
}
}


void CA::minimumcost(int c1,int cst)
{
tmppath.push_back(c1);
if(c1==sv)
{
if(cst<mincost)
{
mincost=cst;
bestpath=tmppath;
}

}
int i;
for(i=0;i<path[c1].size();i++)
{
minimumcost(path[c1][i],cst+cost[c1][path[c1][i]]);
tmppath.pop_back();
}
}


int main()
{
//freopen("test","r",stdin); 
CA *a=new CA;
//a->init();
a->run();
return 0;
}
【系统移植】 移植主线U-Boot(v2024.01-rc3)到RK3399 [系统移植] 移植主线U-Boot(v2024.01-rc3)到RK3399 阅读详情

相关推荐

U盘安装单系统ubuntu10.04之全过程&拔掉U盘后系统无法启动

借助U盘把电脑装成ubuntu单系统之过程记录,以及遇到拔掉U盘后系统无法启动问题,电脑就显示: Non-System disk or disk error, replace and strike any key when ready

CXHPLY的专栏 8680

1030. Travel Plan (30) - Dijkstra

1030. Travel Plan (30)题目地址/* http://www.patest.cn/contests/pat-a-practise/1030 1030. Travel Plan (30) 此题用数组 把city结构体分开用变量 一直是内存超限??换成vector 加结构体的模式 就ok 了 另外 vector 使用resize() assign() 要会 */ #include <i

master-dragon的专栏 1224

VSCode+Keil高效开发STM32:Keil Assistant插件配置全攻略

本文详细介绍了如何通过VSCode的Keil Assistant插件,将Keil MDK的编译调试能力与VSCode的现代编辑体验相结合,打造高效的STM32开发环境。文章涵盖了从环境配置、工程导入、智能提示设置到与STM32CubeMX协同工作的全流程攻略,旨在解决Keil编辑器效率低下的痛点,大幅提升嵌入式开发的编码与项目管理效率。

gold的博客 508

http://pat.zju.edu.cn/contests/pat-practise/1030

1030. Travel Plan (30) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A traveler's map gives the distances between

我不要写标题 841

UE5实战技巧:TextRender高效集成中文字体与材质优化

本文针对UE5中TextRender组件显示中文的常见问题,提供了一套完整的实战解决方案。详细讲解了如何通过手动创建字体资产、精准控制字符集来优化性能,并重点介绍了通过调整材质中的Lerp节点参数(如设为-85, 92)来解决中文字体显示残缺和边缘模糊等核心难题,帮助开发者实现高效且美观的中文文本渲染。

weixin_28040125的博客 381

CSM中一些常见问题的解决方式

CSM中一些常见问题的解决方式 抖动 摄像机在每帧移动或者旋转时,会产生较严重的抖动问题。

小龙虾的博客 2131

1030. Travel Plan (30)

原题如下: A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide th...

weixin_30367873的博客 168

【影像组学入门百问】1#---#3

理论上讲三大主流平台Windows, Linux和MacOS均可进行影像组学研究。根据笔者实际经验,如果内存不足可能导致软件罢工,其余显示、GPU等均非必要。显示:最小分辨率为1024×768(推荐为1280×1024或更好)。Slicer中的许多计算都是多线程的,并且将受益于多核,多CPU配置。计算机需要足够的内存和图形功能将原始数据和处理结果保存在其内存中。如涉及深度学习等方法的研究需根据实际需求配置电脑,无法一概而论。接口设备:推荐使用带滚轮的三键鼠标。内存:超过4GB(推荐8G以上)。

weixin_38594676的博客 1484

PAT甲级 1030 Travel Plan (30分)

1030 Travel Plan (30分) 题目链接:PAT A 1030 题目大意:题目第一行输入给出顶点数,边数,起点和终点,随后几行给出每条边的距离和通过每条边的开销,要求输出最短路径所经过的点以及这条路径的总距离以及总开销。如果有多条同样距离的路径,则输出花销最少的那条路径~ 思路分析:很简单的一道dijkstra算法模板题,只要熟练掌握dijkstra算法就可以解出。有两种解法,一种...

weixin_43684054的博客 527

Ardupilot二次开发(二):自定义mavlivk消息

在下面的文件添加自定义消息的xml定义然后编译固件,会生成相应的消息头文件。

超维空间科技的博客 2314

Python与ArcGIS系列(二)获取地图文档

在ArcPy中,要引用当前的地图文档(Map Document),可以使用 mapping 模块中的 MapDocument 类。值得注意的是,在arcgis内部python窗口运行该代码才能访问已加载进arcgis的文档,如果通过其他idle则无法访问。要引用磁盘上的地图文档并对其进行一些设置,同样可以使用ArcPy中的 mapping 模块和 MapDocument 类。对于我们平常的工作,接触最多的就是图层数据处理,获取图层后就可以方便地进行下一步处理。

weixin_43894929的博客 2200

【1030】Travel Plan (30 分)

#include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> #include<map> #include<vector> #inclu...

发现问题,并解决问题,批判性思维 754

15、目标检测模型的评估指标与YOLO算法解析

本文详细解析了目标检测模型的评估指标,包括精确率、召回率、AP、mAP及IoU的定义与作用,并深入介绍了YOLO算法的核心原理与推理流程。从网格划分、锚框引入到边界框细化与后处理,全面阐述了YOLO如何实现快速准确的目标检测。同时总结了YOLO在智能安防、自动驾驶和工业检测等领域的应用,并展望了其未来在准确性提升、多类别支持和技术融合方面的发展趋势。

work3的博客 66

1030 Travel Plan (30 分)

1030 Travel Plan (30 分) A traveler’s map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to de...

92377 357

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

1030.Travel Plan (30)

题目链接:https://www.patest.cn/contests/pat-a-practise/1030题目大意:给一个图,对于每条边给出边的长度(城市距离)和边的权重(旅行花销)。然后给出起点和终点,求出两点之间的最短路径,若有重复则取边的总权值(总花销)最小的那条。解题思路: 本题目与另一道PAT 1003思路相同,都是使用Dijkstra最短路径算法。 区别是:要将路径输出。在求最短路

NJU_Flipped的博客 524

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

1030 Travel Plan (30 分)

1030Travel Plan(30 分) A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a travele...

weixin_30732487的博客 204

WINCC7.3破解文件

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

1030 Travel Plan (30 分)

1030Travel Plan(30分) A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to d...

weixin_42105789的博客 305

1030 Travel Plan (30分)

1030Travel Plan(30分) A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to de...

雪之下 240
上一篇: 1029 Median (25)
下一篇: 1031 . Hello World for U (20)
河马在奋斗
博客等级 码龄15年 0粉丝 27原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值