P4779【模板】单源最短路径(标准版)(dij)
发布日期:2021-06-27 21:40:29
浏览次数:3
分类:技术文章
本文共 580 字,大约阅读时间需要 1 分钟。
单源最短路径
解题思路
dij模板
AC代码
#include#include #include using namespace std;int n,m,s,tot,c[100005],head[100005];long long d[100005];priority_queue > q;//队列struct node{ int to,next,z;}a[200005];void add(int x,int y,int z){ a[++tot]=(node){ y,head[x],z}; head[x]=tot;}void dij()//dij{ memset(d,0x7f,sizeof(d)); d[s]=0; q.push(make_pair(0,s)); while(!q.empty()) { int x=q.top().second; q.pop(); if(c[x])continue; c[x]=1; for(int i=head[x];i;i=a[i].next) if(!c[a[i].to]&&d[x]+1ll*a[i].z
谢谢
转载地址:https://blog.csdn.net/weixin_45524309/article/details/117082795 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
初次前来,多多关照!
[***.217.46.12]2024年03月30日 03时27分07秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
004_变量的声明以及获取
2019-04-27
005_变量的引用与赋值
2019-04-27
006_关于变量定义的状态
2019-04-27
007_shell中把变量重置为null
2019-04-27
008_shell创建只读量
2019-04-27
009_shell中从标准输入信息
2019-04-27
010_bash脚本的参数传递
2019-04-27
011_命令行参数的左移
2019-04-27
012_bash中的if判断条件
2019-04-27
013_bash中的加法
2019-04-27
014_bash中的for循环
2019-04-27
015_Arduino上实现一个简单的番茄时钟
2019-04-27
021_Excel的条件格式
2019-04-27
022_Excel空白值批量填充默认值
2019-04-27
023_emacs git-gutter+报错解决
2019-04-27
024_spacemacs支持org-pomodoro的声音提示
2019-04-27
025_everything搜索使用体验
2019-04-27
026_好用的windows小工具clover
2019-04-27
027-Mac触摸板实现窗口移动
2019-04-27
028_AUTOSAR RTE学习笔记-1
2019-04-27