上一页 1 ··· 46 47 48 49 50 51 52 53 54 ··· 71 下一页
摘要: http://poj.org/problem?id=3020最小路径覆盖,拆点,总结点数 = 匹配数*2+未匹配节点,所以所用天线数就等于匹配数+未匹配数=总结点-匹配数。由于拆点后,多加了边,匹配数变成了原来的2倍,有向图-》无向图,匹配数增加的是一样的。View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 using namespace std; 6 int link[500],map[500][500],ma[50 阅读全文
posted @ 2013-01-18 21:10 _雨 阅读(165) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1422题意:一个镇上有很多街道,很多十字路口,无循环,把伞兵放在各个十字路口上,使之能把所有的街道都走过,求最小的伞兵数。最小路径覆盖=节点数-最大匹配。模板题View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int map[200][200],link[200],vis[200]; 6 int find(int x,int n) 7 { 8 int i,j; 9 阅读全文
posted @ 2013-01-18 18:49 _雨 阅读(187) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2226模板抄错,结果错了一下午。将连续横行上的*和连续纵桁上点分别看做两个点集,连接两集合中点的边就是图中的点。即求最小顶点覆盖最多的边。最小点覆盖=最大匹配。有篇图片的讲解,挺好,很形象。http://ip96cns.blog.163.com/blog/static/170095192201117465473/View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 in 阅读全文
posted @ 2013-01-18 16:52 _雨 阅读(216) 评论(0) 推荐(0) 编辑
摘要: http://kicd.blog.163.com/blog/static/126961911200910168335852/近年的acm竞赛中,数学期望问题常有涉及,在以前也常让本人感到很头疼,近来突然开窍,掌握了基本的分析方法,希望对大家有帮助。写得浅薄,可能数学上不够严谨,只供理解。 首先,来看下期望有啥基本的公式。对离散型随机变量x,其概率为p,有对随机变量A、B,有第二条式子是今天的主角,他表明了期望有线性的性质,简单理解就是期望之间可根据关系,简单运算(不严谨的理解)。这就为我们解决一个期望问题,不断转化为解决另外的期望问题,最终转化到一个已知的期望上。举一个求期望最简单的例子,见. 阅读全文
posted @ 2012-12-15 21:45 _雨 阅读(338) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1035以前做过很类似的 四种情况分开讨论View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 char str[10010][20],cs[10010][20]; 7 int kk[10010]; 8 int judge1(char *x,char *y) 9 { 10 int i,j,k=0; 11 for(i 阅读全文
posted @ 2012-12-14 19:49 _雨 阅读(130) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3436刚开始做的没拆点 BFS的时候保存了下路径 恰好样例都过了 接着就是各种WA搜了搜解题报告 是将一个电脑拆成2个点 这两点之间限制容量 电脑与电脑之间容量为INF 设置一个源点和汇点 源点全是0 汇点全是1不用保存路径 在最后 比较一下现在的容量和原始容量 差值就为WView Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue 阅读全文
posted @ 2012-12-14 13:27 _雨 阅读(177) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3267对dp没研究 看了看解题报告 还是比较好推的 dp[i] = min{dp[i]-1,dp[j]+i-j-length[k]} 若从J到i包含字典中的单词View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 char word[650][30]; 7 int main() 8 { 9 int i,j,k,n, 阅读全文
posted @ 2012-12-13 17:37 _雨 阅读(149) 评论(0) 推荐(0) 编辑
摘要: QC的博客搬来http://www.cnblogs.com/pony1993/archive/2012/07/28/2612883.html模板题poj1273http://www.cnblogs.com/pony1993/archive/2012/07/28/2612883.html代码View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 #define INF 阅读全文
posted @ 2012-12-12 18:44 _雨 阅读(183) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3026BFS求出任意两个A或A和S的最短距离 然后最小生成树求和把所有A和S存起来求BFS任意两点 搜超时了 之后改了改过了View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 #define INF 0x3f3f3f 8 struct node 9 { 10 int 阅读全文
posted @ 2012-12-11 17:18 _雨 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 【基本概念】:二分图:二分图又称作二部图,是图论中的一种特殊模型。 设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同的顶点集(i in A,j in B),则称图G为一个二分图。无向图G为二分图的充分必要条件是,G至少有两个顶点,且其所有回路的长度均为偶数。最大匹配:给定一个二分图G,在G的一个子图M中,M的边集中的任意两条边都不依附于同一个顶点,则称M是一个匹配. 选择这样的边数最大的子集称为图的最大匹配问题,如果一个匹配中,图中的每个顶点都和图中某条边相关联,则称此匹配为完全匹配,也称作完备匹. 阅读全文
posted @ 2012-12-11 17:12 _雨 阅读(379) 评论(0) 推荐(0) 编辑
上一页 1 ··· 46 47 48 49 50 51 52 53 54 ··· 71 下一页