图论
文章平均质量分 67
ChasingWaves
这个作者很懒,什么都没留下…
展开
-
hdu 3549 Flow Problem (第二篇) Dinic算法 最大流问题
加了一个预处理的bfs优化,这个算法更快原创 2014-07-25 20:28:13 · 381 阅读 · 0 评论 -
POJ 1274 The Perfect Stall 二分图最大匹配
这两天被线段树懒惰标记搞得原创 2014-07-30 16:43:38 · 377 阅读 · 0 评论 -
POJ 2112 Optimal Milking 二分图多重匹配 网络流+Floyd+二分
超级经典的一道题目。。竟然1A 了,原创 2014-07-31 11:48:02 · 516 阅读 · 0 评论 -
POJ 3155 Hard Life 最大密度子图
题目大意:给出一个无向连通图, 找出一个子图,使该子图的边数与点数的比值最大。(最大密度子图)转载 2014-07-27 11:14:07 · 395 阅读 · 0 评论 -
hdu 1285 确定比赛名次 拓扑排序
//31MS 332K#include #include #include #include #include using namespace std;const int MAX_N = 500 + 5;vector G[MAX_N];int in_d[MAX_N];int c[MAX_N];//bool vis[MAX_N];int N, num;bool topo原创 2014-08-06 13:18:50 · 355 阅读 · 0 评论 -
hdu 4284 Travel Floyd+TSP
#include #include #include #include #include using namespace std;const int MAX_N = 100 + 5;const int MAX_M = 5000 + 5;const int INF = 0x7fffffff;int d[MAX_N][MAX_N];int dp[1<<15];struct n原创 2014-08-02 16:36:53 · 388 阅读 · 0 评论 -
POJ 1466 Girls and Boys 最大独立集
无向图的最大独立集 = 顶点数 - 最小顶点覆盖而,原创 2014-08-10 16:25:30 · 394 阅读 · 0 评论 -
使用优先队列的Dijkstra算法
/*有些小问题,求指正*/#include #include #include #include #include #include using namespace std;#define MAXN 100#define MAXM 4950#define INF 1e9typedef pair piiint n, m;int first[MAXN]; //first[原创 2014-01-16 17:20:55 · 639 阅读 · 0 评论 -
WOJ校赛 Problem 1542 - F - Countries 并查集+离散化+Floyd
DescriptionThere are n countries at planet X on which Xiao Ming was born.Some countries, which have been sharing fine bilateral relations, form a coalition and thus all of their citizens w原创 2014-04-01 17:10:21 · 538 阅读 · 0 评论 -
POJ 1703 Find them, Catch them 二分图 并查集
//636K 313MS#include const int N = 100005;int n, m, f[N];bool rank[N];inline void init(){ for(int i=1; i<=n; ++i){ f[i]=i; rank[i]=0; //初始化所有点都在二分图的一边 }}int find(int原创 2014-07-21 00:34:17 · 429 阅读 · 0 评论 -
hdu 1532 Drainage Ditches 最大流 水题
//0MS 268K#include #include #include #include #include #include using namespace std;struct edge{ int to, cap, rev; edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev)原创 2014-07-27 16:39:21 · 339 阅读 · 0 评论 -
hdu 3549 Flow Problem 最大流模板题 Ford-Fulkerson算法
好久都没在杭电上做题了。。裸的最大流模板题。。原创 2014-07-25 17:15:29 · 437 阅读 · 0 评论 -
POJ 3268 Silver Cow Party
给出n个点和m条边,接着是m条边,代表从牛a到牛b需要花费c时间,现在所有牛要到牛x那里去参加聚会,并且所有牛参加聚会后还要回来,给你牛x,除了牛x之外的牛,他们都有一个参加聚会并且回来的最短时间,从这些最短时间里找出一个最大值输出原创 2014-07-23 11:11:11 · 376 阅读 · 0 评论 -
POJ 3259 Wormholes
题意是判断一个有向图是否存在负环。原创 2014-07-22 11:44:04 · 318 阅读 · 0 评论 -
POJ Six Degrees of Cowvin Bacon
刷点水题,调整一下心情原创 2014-07-21 17:13:33 · 424 阅读 · 0 评论 -
POJ 2236 Wireless Network 并查集
裸的并查集问题,我是用的可行数组存的,至于原创 2014-07-20 15:36:25 · 357 阅读 · 0 评论 -
POJ 3255 Roadblocks 次短路
求次短路,模板题//2788K 235MS#include #include #include #include #include #include using namespace std;typedef pair pii;const int maxn = 5000;const int maxm = 100000;const int inf = 0x7fffffff;ve原创 2014-07-24 11:30:30 · 378 阅读 · 0 评论 -
POJ 2377 Bad Cowtractors
最大生成树//376K 32MS#include #include #include #include using namespace std;struct edge{ int u, v, cost; edge(int u=0, int v=0, int cost=0) : u(u), v(v), cost(cost){ }};const int max原创 2014-07-23 17:08:48 · 344 阅读 · 0 评论 -
poj 2914 Minimum Cut 求无向图的最小割 Stoer-Wagner算法模板
用求最大流的方法去求最小割,C(n,2)枚举原创 2014-07-26 20:42:46 · 467 阅读 · 0 评论 -
Kruskal算法模板
#include #include #include using namespace std;#define MAXVEXNUM 10#define MAXEDGENUM 100int u[MAXEDGENUM], v[MAXEDGENUM], r[MAXEDGENUM], p[MAXVEXNUM];double w[MAXEDGENUM];//第i条边的两个端点序号和权值分别原创 2014-01-14 16:05:15 · 496 阅读 · 0 评论