随笔分类 -  图论

1 2 下一页
pku 1149最大流(标号法)
摘要:1 /* 2 * 一般增广路算法--Ford_Fulkerson算法(标号法) 3 */ 4 /* 5 建图:将顾客看作除源点和汇点以外的节点,源点和每个猪圈的第一个顾客连边,边的权是开始时猪 6 圈中猪的数目,若源点和某个节点之间有重边,则将权合并,顾客j紧跟在顾客i之后打开某个猪圈, 7 则边<i,j>的权是+∞,每个顾客和汇之间连边,边的权是顾客所希望购买的猪的数目。 8 */ 9 10 #include <cstdio>11 #include <cstring>12 #include <iostream>13 14 using names 阅读全文
posted @ 2012-05-30 22:25 Try86 阅读(783) 评论(0) 推荐(0)
pku 2253(floyd变形)
摘要:View Code /* Name: floyd Copyright: Author: Date: 19/04/12 22:39 Description: 求所有连接1跟2的路径中,最大边权中的最小值 */#include <cmath>#include <cstdio>#include <iostream>using namespace std;const int N = 205;double dis[N][N];struct point { double x; double y;}p[N];double max(double a, double b) { 阅读全文
posted @ 2012-04-19 22:46 Try86 阅读(131) 评论(0) 推荐(0)
pku 3268(SPFA)
摘要:View Code /* Name: bellmanFord算法的改进-->SPFA算法 Copyright: Author: Date: 18/04/12 22:29 Description: 从x点正向求最短路及反向求最短路,累加最短时间,取最短时间的最大者 */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 1005;const int M = 100000;const i 阅读全文
posted @ 2012-04-19 07:02 Try86 阅读(134) 评论(0) 推荐(0)
pku 1797利用kruskal算法的过程
摘要:View Code /* Name: 利用kruskal算法的过程 Copyright: Author: Try86 Date: 18/04/12 20:58 Description: 求所有从起点到终点的路径上的最小边权的最大值 */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 1005;const int M = 1000005;int p[N], n, m;struct edge { int u; int v; int w; 阅读全文
posted @ 2012-04-18 21:05 Try86 阅读(153) 评论(0) 推荐(0)
pku 2263利用kruskal的过程+hash+二分
摘要:View Code /* Name: 利用kruskal的过程+hash+二分 Copyright: (处理字符串我写复杂了!) Author: Try86 Date: 18/04/12 20:26 Description: 求连接两点的路径上的最小边权的最大值 */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int L = 35;const int S = 331;//hash表大小 const 阅读全文
posted @ 2012-04-18 20:39 Try86 阅读(161) 评论(0) 推荐(0)
hdu 1217最短路(bellmanFord)
摘要:View Code /* Name: 最短路(bellmanFord) Copyright: Author: Try86 Date: 18/04/12 13:50 Description: 判断是否从某一种货币出发经过一系列的转换后回到自身时,货币币值增加 */#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>using namespace std;const int N = 35;const int M = 1000;double d[N];char 阅读全文
posted @ 2012-04-18 17:32 Try86 阅读(180) 评论(0) 推荐(0)
pku 1094(拓扑排序,多次拓扑)
摘要:View Code /* Name: 拓扑排序,多次拓扑 Copyright: Author: Try86 Date: 16/04/12 21:36 Description: */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 27;bool ch[N];char ans[N]; //存拓扑序 int inDeg[N]; //入度数 struct node { int v; node 阅读全文
posted @ 2012-04-16 22:06 Try86 阅读(146) 评论(0) 推荐(0)
hdu 2647(拓扑排序,判断有向图是否存在回路及自环,并统计每个顶点的前驱点数)
摘要:View Code /* Name: 拓扑排序,判断有向图是否存在回路及自环,并统计每个顶点的前驱点数 Copyright: Author: Try86 Date: 15/04/12 22:25 Description: */#include <queue>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 10005;int sum, flag;int counts[N];s 阅读全文
posted @ 2012-04-15 22:38 Try86 阅读(753) 评论(0) 推荐(0)
hdu 3342(利用拓扑排序过程判断有向图是否有回路及自环)
摘要:View Code /* Name: 利用拓扑排序过程判断有向图是否有回路及自环 Copyright: Author: Try86 Date: 15/04/12 21:15 Description: */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 105;int color[N], flag;struct node { int v; node *next; node(int vv, 阅读全文
posted @ 2012-04-15 21:31 Try86 阅读(332) 评论(0) 推荐(0)
hrbustOJ 最小生成树问题(kruskal)
摘要:View Code /* Name: 最小生成树(kruskal) Copyright: Author: Try86 Date: 15/04/12 08:01 Description: */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 10005;const int M = 50005;int p[N], sum;struct edge { int u; int v; int w;}e[M];int cmp(const void 阅读全文
posted @ 2012-04-15 08:10 Try86 阅读(200) 评论(0) 推荐(0)
hrbustOJ 欧拉路径(判断无向图是否连通+统计顶点的度数)
摘要:/* Name: 判断无向图是否连通+统计顶点的度数 Copyright: Author: Try86 Date: 14/04/12 23:02 Description: 邻接链表存图 */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 105;int deg[N]; //统计顶点的度数 bool map[N][N], color[N];struct node { int v; nod 阅读全文
posted @ 2012-04-15 07:36 Try86 阅读(534) 评论(0) 推荐(0)
pku 1659(判断可图化Havel-Hakiwi定理的应用)
摘要:/* Name: Havel-Hakiwi定理的应用 Copyright: Author: Try86 Date: 13/04/12 23:16 Description: */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;int map[15][15], flag;struct node { int deg; //顶点度数 int ver; //顶点编号 }d[15];int cmp(const void *a 阅读全文
posted @ 2012-04-14 07:42 Try86 阅读(230) 评论(0) 推荐(0)
hdu 2112(最短路+hash+二分)
摘要:/* Name: 最短路(dijkstra邻接矩阵)+hash判重并统计顶点数+二分查找返回顶点位置 Copyright: Author: Try_86 Date: 12/04/12 20:57 Description: 注意:起始点和终点不在给出的路线中的情况!!! */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int S = 163; const int N = 155;const int 阅读全文
posted @ 2012-04-12 21:15 Try86 阅读(196) 评论(0) 推荐(0)
hdu 2544 最短路(dijkstra邻接矩阵)
摘要:/* Name: 最短路(dijkstra邻接矩阵) Copyright: Author: Try_86 Date: 12/04/12 18:09 Description: */#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int N = 105; const int MAX = 1000000000;//定义无穷大 bool vis[N];int map[N][N], dis[N];void init(int vs) {//初始化 for (i 阅读全文
posted @ 2012-04-12 18:21 Try86 阅读(192) 评论(0) 推荐(0)
hdu 2066(最短路bellmanFord)
摘要:/* Name: 最短路(bellmanFord) Copyright: Author: Try_86 Date: 12/04/12 12:42 Description: 对每个起始点运行一次bellmanFord,求最短路 */#include <cstdio>#include <iostream>using namespace std;const int N = 1005;const int M = 500500;const int MAX = 1000000000;int dis[N], ss[N], ds[N];struct edge { int u; int. 阅读全文
posted @ 2012-04-12 12:47 Try86 阅读(254) 评论(0) 推荐(0)
hdu 3790(最短路BellmanFord)
摘要:984MS,真险!Bellman_Frod效率不高啊!/* Name: 最短路(bellmanFord) Copyright: Author: Try_86 Date: 11/04/12 21:16 Description: */#include <cstdio>#include <iostream>using namespace std;const int N = 1005;const int M = 200005;const int MAX = 1000000000;int dis[N], cs[N];struct edge { int u; int v; ... 阅读全文
posted @ 2012-04-11 21:19 Try86 阅读(284) 评论(0) 推荐(0)
hdu 2680(最短路bellmanFord)
摘要:843MS,差点就超时!/* Name: 最短路(bellmanFord) Copyright: Author: Try_86 Date: 11/04/12 20:39 Description: 建反向图,求终点到各点的最短路 */#include <cstdio>#include <iostream>using namespace std;const int N = 1005;const int M = 40005;const int MAX = 1000000000;int dis[N];struct edge { int u; int v; int w;}... 阅读全文
posted @ 2012-04-11 20:45 Try86 阅读(193) 评论(0) 推荐(0)
hdu 2544 最短路(Bellman_Ford)
摘要:/* Name: 最短路(Bellman_Ford) Copyright: Author: Try_86 Date: 11/04/12 19:56 Description: */#include <cstdio>#include <iostream>using namespace std;const int N = 205;const int M = 20005;const int MAX = 1000000000;int dis[N];struct edge { int u; int v; int w;}e[M];void init(int vs, int s... 阅读全文
posted @ 2012-04-11 20:04 Try86 阅读(195) 评论(0) 推荐(0)
hdu 1874(最短路Bellman_Ford)
摘要:/* Name: 最短路(bellmanFord) Copyright: Author: Try_86 Date: 11/04/12 19:03 Description: 求一对顶点间的最短路 注意:建立反向边时两端点的顺序 */#include <cstdio>#include <climits>#include <iostream>using namespace std;const int N = 205;const int M = 2005;const int MAX = 100000000;int dis[N]; struct edge {//边结点 阅读全文
posted @ 2012-04-11 19:40 Try86 阅读(280) 评论(0) 推荐(0)
hdu 1301(最小生成树kruskal)
摘要:/* Name: 最小生成树(kruskal) Author: Try_86 Date: 10/04/12 19:51*/#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int M = 700;int p[27], sum;struct edge { int a; int b; int w;}e[M];int cmp(const void *a, const void *b) { return (*(edge *)a).w - (*(edge *) 阅读全文
posted @ 2012-04-10 19:53 Try86 阅读(240) 评论(0) 推荐(0)

1 2 下一页