摘要: c.单点更新 /* 线段树 单点更新 */ #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define L(root) ((root)<<1) #define R(root) (((root 阅读全文
posted @ 2016-04-07 20:35 gongpixin 阅读(256) 评论(0) 推荐(0)
摘要: c. /* 树状数组 */ #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int n,c[50005]; int lowbit(int i){ return i&-i; } void upda 阅读全文
posted @ 2016-04-07 20:31 gongpixin 阅读(222) 评论(0) 推荐(0)
摘要: 1.最大流 ps:直接以题目来看模板的使用 POJ - 1459 Power Network(最大流)(模板) d.看了好久,囧。 n个节点,np个源点,nc个汇点,m条边(对应代码中即节点u 到节点v 的最大流量为z) 求所有汇点的最大流。 s.多个源点,多个汇点的最大流。 建立一个超级源点、一个 阅读全文
posted @ 2016-04-07 20:13 gongpixin 阅读(332) 评论(0) 推荐(0)
摘要: 多源最短路径 c.floyd /* 多源最短路径 floyd */ #include<iostream> #include<stdio.h> using namespace std; #define MAXN 1010 #define typec int #define INF 0x3f3f3f3f 阅读全文
posted @ 2016-04-07 20:06 gongpixin 阅读(223) 评论(0) 推荐(0)
摘要: 1.Prim算法:cost[a][b]和cost[b][a]都得赋值。 /* Prim算法 Prim求MST 耗费矩阵cost[][],标号从0开始,0~n-1 返回最小生成树的权值,返回-1表示原图不连通 */ #include<iostream> #include<stdio.h> #inclu 阅读全文
posted @ 2016-04-07 20:03 gongpixin 阅读(220) 评论(0) 推荐(0)
摘要: c. /* 并查集模板 */ #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define MAXN 1024 int fa[MAXN]; int set_find(int d){ if(fa 阅读全文
posted @ 2016-04-07 20:02 gongpixin 阅读(205) 评论(0) 推荐(0)