首页 > 小木乃伊到我家
头像 威风镰鼬
发表于 2021-06-15 14:57:41
思路 写一个Dijkstra堆优化的模板供大家参考一下。(码风比较丑,不要介意) 代码 #include<bits/stdc++.h> using namespace std; const int maxn=200005,maxm=500005; struct E{ int n 展开全文
头像 刘来也
发表于 2024-02-20 00:43:55
写着道题目气死我自己,一直没有注意是无向图题目,WA了半天....... 来个纯数组的Dijsktra, #include <iostream> #include <algorithm> #include <queue> #include <cstring& 展开全文
头像 懒散之魂
发表于 2022-02-22 20:47:54
一手BellmanFord算法送给大家(感觉应该是最容易写的) 我把自己给坑到了!注意此题是无向图,所以两个方向的边都需要存下! #include<bits/stdc++.h> using namespace std; using ll = long long; struct no 展开全文
头像 Dayline
发表于 2020-09-10 20:46:03
最短路模板,加一个判断一下最后一步dis[n]与inf关系,若大于等于,那就输出qwb baka就成。 #include <bits/stdc++.h> using namespace std; int n,m; const int maxn=200005; const int in 展开全文
头像 an_da
发表于 2021-05-15 21:49:43
dijkstra解法 1.距离要初始化为inf2.边的存储要弄清存储的方式,以及各自代表的含义;比如说pair存储,first代表边的指向的点,second代表边的权值,而数组的第一维代表边的起点。3.优先队列存储的信息要清楚它的作用:存储距离:目的是对距离进行排序,每次取出距离最小的节点,功能只是 展开全文