图论
图论
flyzer
这个作者很懒,什么都没留下…
展开
-
网络流 最小费用最大流
网络流裸题 HDU 3549 Sample input: 2 3 2 1 2 1 2 3 1 3 3 1 2 1 2 3 1 1 3 1 Sample output: Case 1: 1 Case 2: 2 #include<iostream> #include<cstdio> #include<cstring> #include<alg...原创 2018-07-29 14:51:55 · 559 阅读 · 0 评论 -
HDU 1532 网络流裸题
转自:https://blog.csdn.net/qq_38987374/article/details/80083754 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1532 标准的网络流裸题 #include<iostream> #include<cstdio> #include<cstring> #in...转载 2018-07-28 12:56:42 · 858 阅读 · 0 评论 -
HDU 6386 SPFA变形
HDU 6386 spfa变形 (要求的是2500ms,我是2秒多水过......) 补了差不多两个星期,终于做出来了。 #include<bits/stdc++.h> #define inf 1000000000 const double pi=acos(-1.0); using namespace std; const int N=100010; int n,m; str...原创 2019-05-11 18:03:45 · 168 阅读 · 0 评论 -
Dijkstra、Bellman_Ford、SPFA、Floyd算法复杂度比较
转自:Dijkstra、Bellman_Ford、SPFA、Floyd算法复杂度比较 Dijkstra:适用于权值为非负的图的单源最短路径,用斐波那契堆的复杂度O(E+VlgV) BellmanFord:适用于权值有负值的图的单源最短路径,并且能够检测负圈,复杂度O(VE) SPFA:适用于权值有负值,且没有负圈的图的单源最短路径,论文中的复杂度O(kE),k为每个节点进入Queue的次数,...转载 2018-06-11 17:14:56 · 1503 阅读 · 1 评论 -
SPFA算法 最短路
spfa求最短路 有一篇讲解spfa的博客,讲的不错:最快最好用的——spfa算法 POJ 2387 Til the Cows Come Home 最短路裸题 input: 5 5 1 2 20 2 3 30 3 4 20 4 5 20 1 5 100 output: 90 直接模拟spfa算法过程: #include <iostream> #include &...原创 2018-06-11 16:18:05 · 300 阅读 · 1 评论 -
最快最好用的——spfa算法
转自:https://blog.csdn.net/xunalove/article/details/70045815 求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm。 SPFA算法是西南交通大学段凡丁于1994年发表的。 从名字我们就可以看出,这种算法在效率上一定有过人之处。 很多时候,给定的图存在负权边,这时...转载 2018-06-06 09:08:26 · 564 阅读 · 0 评论 -
Dijkstra最短路算法和Floyd最短路算法
Dijkstra最短路算法 转自:http://blog.51cto.com/ahalei/1387799 时间复杂度O(n^2) 空间复杂度O(n^2) 邻接矩阵存储 #include <stdio.h> int main() { int e[10][10],dis[10],book[10],n,m,t1,t2,t3,minn; int inf=999...转载 2018-05-29 21:02:37 · 226 阅读 · 0 评论 -
巧妙的邻接表(数组实现)
转自:http://www.cnblogs.com/ahalei/p/3651334.html 巧妙的邻接表(数组实现) 之前我们介绍过图的邻接矩阵存储法,它的空间和时间复杂度都是N2,现在我来介绍另外一种存储图的方法:邻接表,这样空间和时间复杂度就都是M。对于稀疏图来说,M要远远小于N2。先上数据,如下。 4 5 1 4 9 4 3 8 1 2 5 2 4...转载 2018-04-13 09:02:27 · 2161 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home 最短路
题目连接 Til the Cows Come Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 66264 Accepted: 22300 Description Bessie is out in the field and wants to get back to t...原创 2018-04-12 20:49:25 · 183 阅读 · 0 评论 -
最小生成树Kruskal算法
HDU 1301 题意:题干给出原先的图,其中有n个点,给出n-1个点的关系,问连接所有点之后最小路径和 并查集+结构体排序 Kruskal算法 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define ll long long int s...转载 2018-05-29 21:22:49 · 128 阅读 · 0 评论