![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
最短路
永夜莫明
菜是原罪
展开
-
Til the Cows Come Home
#include#include#include#includeusing namespace std;struct node{int v,w;//后继结点与权值node(){}node(int vv,int ww){v=vv;w=ww;} };struct Node{int u,w;//前驱结点与权值Node(){}Node(int uu,int ww) {u...原创 2018-11-19 22:03:41 · 174 阅读 · 0 评论 -
百度之星初赛三 最短路2(Dijkstra)
小 A 是社团里的工具人,有一天他的朋友给了他一个 n 个点,m 条边的正权连通无向图,要他计算所有点两两之间的最短路。作为一个工具人,小 A 熟练掌握着 floyd 算法,设 w[i][j] 为原图中 (i,j) 之间的权值最小的边的权值,若没有边则 w[i][j]=无穷大。特别地,若 i=j,则 w[i][j]=0。Floyd 的 C++ 实现如下:for(int k=1;k&l...原创 2019-08-24 17:10:25 · 534 阅读 · 12 评论 -
路(最短路路径+枚举+dj,邻接矩阵存图)
问题 F: 路时间限制: 1 Sec内存限制: 128 MB提交: 200解决: 50[提交] [状态] [命题人:admin]题目描述Farmer John 热衷于散步,每天早上他都要从 1 号仓库走到 n 号仓库。 Farmer John 家的 n 个仓库被 m 条双向道路连通起来,每条道路有一个长度 w。而Farmer John 又不喜欢走路,所以他走的是从 1 ...原创 2019-07-30 18:56:58 · 392 阅读 · 0 评论 -
Bear and Clique Distances(构造基点+Dijkstra)
Bearland consists ofNcities, numbered 1 throughN. Cities are connected with bidirectional roads.Cities 1 throughKwere built a long time ago, when citizens liked order and regularity. Each pair ...原创 2019-04-03 00:22:51 · 227 阅读 · 0 评论 -
Paths and Trees (Dijkstra单源最短路+边权值和最小)
Little girl Susie accidentally found her elder brother's notebook. She has many things to do, more important than solving problems, but she found this problem too interesting, so she wanted to know i...原创 2019-02-27 11:18:46 · 254 阅读 · 0 评论 -
最短时间(邻接矩阵Dijkstra)
题目描述梦工厂有 n 个分厂(从 1 开始编号),有m对分厂通过双向铁路相连。为了保证每两个分厂之间的同学可以方便地进行交流,掌舵人张老师就在那些没有铁路连接的分厂之间建造了公路。在两个直接通过公路或铁路相连的分厂之间移动,需要花费 1 小时。现在菜鸡wxy和hbz都从1厂出发,wxy开火车,hbz开汽车,各自前往n厂。但是,他们中途不能同时停在同一个分厂(但是可以同时停在n厂)。现...原创 2019-02-07 20:48:25 · 718 阅读 · 2 评论 -
7-36 旅游规划 (25 分)(多权值最短路)(Dijkstra)
7-36 旅游规划 (25 分)有了一张自驾旅游路线图,你会知道城市间的高速公路长度、以及该公路要收取的过路费。现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径。如果有若干条路径都是最短的,那么需要输出最便宜的一条路径。输入格式:输入说明:输入数据的第1行给出4个正整数N、M、S、D,其中N(2≤N≤500)是城市的个数,顺便假设城市的编号为0~(N−1);M是高速...原创 2018-12-20 20:13:02 · 259 阅读 · 0 评论 -
最短路算法讲解
傻子也能看懂的弗洛伊德算法https://blog.csdn.net/qq_34374664/article/details/52261672傻子也能看懂的迪杰斯特拉算法https://blog.csdn.net/qq_34374664/article/details/52261597spfa 算法详解https://blog.csdn.net/qq_34374664/article/d...转载 2018-11-24 02:26:37 · 180 阅读 · 0 评论 -
Heavy Transportation(Dijkstra变形)
Heavy TransportationBackgroundHugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way fr...原创 2018-11-24 02:21:26 · 287 阅读 · 0 评论 -
六度分离(floyd)
六度分离1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人就可以将他们联系在一起,因此他的理论也被称为“六度分离”理论(six degrees of separation)。虽然米尔格兰姆的理论屡屡应验,一直也有很多社会学家对其兴趣浓厚,但是在30...转载 2018-11-24 02:05:45 · 228 阅读 · 0 评论 -
How Many Maos Does the Guanxi Worth(去掉某一点及其所有的边)(n次Dijkstra求最短路最大值)
How Many Maos Does the Guanxi Worth“Guanxi” is a very important word in Chinese. It kind of means “relationship” or “contact”. Guanxi can be based on friendship, but also can be built on money. So Ch...原创 2018-11-24 01:54:30 · 200 阅读 · 0 评论 -
一个人的旅行 (多源最短路转单源最短路模板)(Dijkstra)
一个人的旅行虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,笑),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时间,可不能浪费啊,一定要给自己好好...原创 2018-11-24 01:16:42 · 325 阅读 · 0 评论 -
最短路径问题(多权值最短路)(Dijkstra)
最短路径问题给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。Input输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点。n和m为0时输入结束。(1<n<=1000, 0&l...原创 2018-11-24 01:11:51 · 1932 阅读 · 0 评论 -
Frogger(Dijkstra变形)
FroggerFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of touri...原创 2018-11-24 01:03:08 · 474 阅读 · 0 评论 -
Silver Cow Party(两次Dijstra)
Silver Cow PartyOne cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1…N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirecti...原创 2018-11-24 00:48:48 · 295 阅读 · 0 评论 -
Til the Cows Come Home(单源最短路)(Dijstra模板题)
Til the Cows Come HomeBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep...原创 2018-11-24 00:34:33 · 239 阅读 · 0 评论 -
Buy a Ticket(多源最短路转单源最短路)(Dijkstra)
Buy a TicketMusicians of a popular band “Flayer” have announced that they are going to “make their exit” with a world tour. Of course, they will visit Berland as well.There are n cities in Berland. ...原创 2018-11-23 18:34:49 · 620 阅读 · 0 评论 -
Anna, Svyatoslav and Maps(思维+folyd求最短路)
http://codeforces.com/contest/1204/problem/CThe main characters have been omitted to be short.You are given a directed unweighted graph without loops withnnvertexes and a path in it (that path i...原创 2019-08-22 01:07:37 · 454 阅读 · 7 评论