摘要: 1 /* 2 这个题目有点意思 3 4 构图需分析,和3041有区别 5 6 3041,是一行可以覆盖。所以在那个题目中,每行和列可作为顶点 7 8 现在的题目,是每段可覆盖,所以每个段作为顶点,如果交叉则有边。 9 10 这样图就构成了 11 */ 12 13 // include file 14 #include <cstdio> 15 #include <cstdlib> 16 #include <cstring> 17 #include <cmath> 18 #include <cctype> 19 #include < 阅读全文
posted @ 2011-03-04 21:39 AC2012 阅读(1327) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 建图,然后二分匹配。求最小点覆盖转化为求最大匹配 3 hungarian算法 4 */ 5 // include file 6 #include <cstdio> 7 #include <cstdlib> 8 #include <cstring> 9 #include <cmath> 10 #include <cctype> 11 #include <ctime> 12 13 #include <iostream> 14 #include <sstream> 15 #include & 阅读全文
posted @ 2011-03-04 19:56 AC2012 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 还有17个 3 4 求最小的顶点覆盖 ,也就是最大匹配,hungarian算法上 5 6 建图的时候,如果有一边是0,说明是开始状态,无须在算 7 */ 8 9 // include file 10 #include <cstdio> 11 #include <cstdlib> 12 #include <cstring> 13 #include <cmath> 14 #include <cctype> 15 #include <ctime> 16 17 #include <iostream> 18 阅读全文
posted @ 2011-03-04 15:57 AC2012 阅读(430) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 要求的是最大独立集 3 4 最大独立集+最小顶点覆盖(最大匹配) = 顶点数 5 6 所以最后的结果为 (顶点数-最大匹配)/2 7 */ 8 9 // include file 10 #include <cstdio> 11 #include <cstdlib> 12 #include <cstring> 13 #include <cmath> 14 #include <cctype> 15 #include <ctime> 16 17 #include <iostream> 18 #inclu 阅读全文
posted @ 2011-03-04 15:10 AC2012 阅读(416) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 找出最少的顶点把所有的边都覆盖了 3 最小顶点覆盖问题= 最大匹配问题 4 可hungarian算法来解决 5 采用邻接标 O(N*M) 6 */ 7 8 // include file 9 #include <cstdio> 10 #include <cstdlib> 11 #include <cstring> 12 #include <cmath> 13 #include <cctype> 14 #include <ctime> 15 16 #include <iostream> 17 #in 阅读全文
posted @ 2011-03-04 14:29 AC2012 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 最大独立集+顶点最小覆盖(最大匹配)=顶点数 3 4 问题的本质回归为 求二分图的最大匹配了 5 6 二分图的最大匹配,可以用hungarian algorithm或者最大流算法来求 7 */ 8 9 // include file 10 #include <cstdio> 11 #include <cstdlib> 12 #include <cstring> 13 #include <cmath> 14 #include <cctype> 15 #include <ctime> 16 17 #include 阅读全文
posted @ 2011-03-04 14:05 AC2012 阅读(548) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 可以用SPFA,把交易区间M内的点拿出来枚举一下就可以了 3 巧妙的构图,把每一个物品的原始价格转变为一条额外的边,可以转化为最短路问题了 4 */ 5 6 // include file 7 #include <cstdio> 8 #include <cstdlib> 9 #include <cstring> 10 #include <cmath> 11 #include <cctype> 12 #include <ctime> 13 14 #include <iostream> 15 #inc 阅读全文
posted @ 2011-03-03 19:51 AC2012 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 图论 3 最短路 4 SPFA算法 5 6 从1到各点的最短距离,个点到1的最短距离,总共1000000点,1000000边 7 8 两次SPFA可以解决问题 9 */ 10 11 // include file 12 #include <cstdio> 13 #include <cstdlib> 14 #include <cstring> 15 #include <cmath> 16 #include <cctype> 17 #include <ctime> 18 19 #include <iostr 阅读全文
posted @ 2011-03-03 18:56 AC2012 阅读(573) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 判断是否存在正环 3 居然还有同种货币的兑换,此点很。。。 4 */ 5 6 // include file 7 #include <cstdio> 8 #include <cstdlib> 9 #include <cstring> 10 #include <cmath> 11 #include <cctype> 12 #include <ctime> 13 14 #include <iostream> 15 #include <sstream> 16 #include <fst 阅读全文
posted @ 2011-03-03 14:53 AC2012 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 bellman_ford算法 3 */ 4 5 // include file 6 #include <cstdio> 7 #include <cstdlib> 8 #include <cstring> 9 #include <cmath> 10 #include <cctype> 11 #include <ctime> 12 13 #include <iostream> 14 #include <sstream> 15 #include <fstream> 16 #inc 阅读全文
posted @ 2011-03-03 14:11 AC2012 阅读(474) 评论(0) 推荐(0) 编辑