
图
谛听-
线上幽灵
展开
-
dfs & bfs
图的构建及打印#include <iostream>#include <queue>#include <vector>using namespace std;const int MAX_V = 100;vector<vector<int>> adj(MAX_V);void AddEdge(int from, int to) { adj[from].push_back(to); adj[to].push_back(from)原创 2021-09-06 21:49:32 · 377 阅读 · 0 评论 -
调用链路的数目和最大的耗时--dfs
小明和每个系统的负责人确认了依赖关系,记录下调用对应系统的耗时,用这些数据分析端到端链路的数目和链路上最长的耗时。输入: 小明搜集到的系统耗时和依赖列表 5 4 // 表示有5个系统和 4个依赖关系 3 // 调用1号系统耗时 3 ms 2 // 调用2号系统耗时 2 ms 10 // 调用3号系统耗时 10 ms 5 // 调用4号系统耗...原创 2018-07-21 20:30:47 · 1601 阅读 · 1 评论 -
zkw最小费用流
http://blog.youkuaiyun.com/zhulei19931019/article/details/69390750转载 2017-05-13 18:51:35 · 646 阅读 · 0 评论 -
两点之间的所有最短路径
#include "iostream"#include "string"#include "fstream"#include "vector"#include "queue"#include "sstream"#include "set"#include "string.h"#include "math.h"#include <functional>using namespace原创 2017-05-02 18:56:27 · 8308 阅读 · 0 评论 -
leetcode---Pacific Atlantic Water Flow---dfs
Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the “Pacific ocean” touches the left and top edges of the matrix and the “Atlantic ocean” touche原创 2017-04-11 17:57:03 · 307 阅读 · 0 评论 -
leetcode---Reconstruct Itinerary---dfs
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the原创 2017-04-09 19:36:15 · 589 阅读 · 0 评论 -
leetcode--- Minimum Height Trees
For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minim原创 2017-03-09 08:57:53 · 326 阅读 · 0 评论 -
单源最短路径---Dijkstra
#include "iostream"#include "vector"#include "string.h"#include "fstream"#include "queue"#include "stdio.h"using namespace std;const int MAX_V = 100;const int INF = 10000;int V; //顶点数int dist原创 2016-04-06 11:48:27 · 348 阅读 · 0 评论 -
拓扑排序
#include "iostream"#include "stack"#include "vector"#include "string.h"#define min(a, b) a < b ? a : busing namespace std;const int MAX_V = 100;int visit[MAX_V]; //1表示已访问过,0表示未访问,-1表示正在访问vecto原创 2016-04-03 18:49:47 · 284 阅读 · 0 评论 -
最小费用流
#include "iostream"#include "stack"#include "vector"#include "string.h"#define min(a, b) a < b ? a : busing namespace std;struct Edge{ int to; //终点 int cap; //容量 int cost; //花费原创 2016-04-03 16:56:51 · 422 阅读 · 0 评论 -
二分图匹配
#include "iostream"#include "stack"#include "vector"#include "string.h"#define min(x, y) x < y ? x : yusing namespace std;int V; //顶点数const int MAX_V = 100; vector<int> G[MAX_V]; //图的邻接表int v原创 2016-04-03 09:39:59 · 386 阅读 · 0 评论 -
最大流
#include "iostream"#include "stack"#include "vector"#include "string.h"#define min(x, y) x < y ? x : yusing namespace std;struct Edge{ int to; //终点 int cap; //容量 int rev; //反向边};con原创 2016-04-03 09:01:57 · 323 阅读 · 0 评论 -
LCA
#include "iostream"#include "stack"#include "vector"#include "string.h"using namespace std;const int MAX_V = 100;vector<int> G[MAX_V]; //图的邻接表int parent[MAX_V];int depth[MAX_V];void addEdge(int原创 2016-04-03 07:39:34 · 348 阅读 · 0 评论 -
2-SAT
#include "iostream"#include "stack"#include "vector"#include "string.h"using namespace std;const MAX_V = 100;vector<int> G[MAX_V]; //图的邻接表vector<int> rG[MAX_V]; //反向图的邻接表int visit[MAX_V]; //原创 2016-04-03 06:48:44 · 387 阅读 · 0 评论 -
强连通分量分解
#include "iostream"#include "stack"#include "vector"#include "string.h"using namespace std;const MAX_V = 100;vector<int> G[MAX_V]; //图的邻接表vector<int> rG[MAX_V]; //反向图的邻接表int visit[MAX_V]; //原创 2016-04-02 22:46:19 · 581 阅读 · 0 评论