摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2458思路:由于要求选出尽可能多的认识的人,那么我们可以反着来考虑,给不认识的女孩和男孩连边,于是问题就转化为求最大独立集。最大独立集=顶点数-最大匹配。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 #define MAXN 222 8 阅读全文
posted @ 2013-06-05 21:55 ihge2k 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4185思路:坐标映射建双向图,只要满足条件构成矩阵,就连边,最后求一下最大匹配即可。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 #define MAXN 360036 8 vector<int>vet[MAXN]; 9 c 阅读全文
posted @ 2013-06-05 21:21 ihge2k 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1507思路:这题关键是建图,我们可以把坐标映射建双向图,最后求得的最大匹配数/2就ok了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 #define MAXN 10010 8 vector<int>map[MAXN]; 9 阅读全文
posted @ 2013-06-05 20:51 ihge2k 阅读(614) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1350http://acm.hdu.edu.cn/showproblem.php?pid=1960思路:最小路径覆盖,即如果两条路线的时间不冲突,那么就连边,最后求一下最大匹配就可以了。最小路径覆盖=顶点数-最大匹配。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 #include&l 阅读全文
posted @ 2013-06-05 19:35 ihge2k 阅读(374) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2768思路:把喜欢cat的和喜欢dog的看成两个集合,如果这两个集合有冲突,即cat.love==dog.hate或者cat.hate==dog.love,这连边,代表有矛盾,那么最后的结果不就是求一下最大独立集吗。最大独立集=顶点数-最大匹配。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string> 5 #include<algorithm&g 阅读全文
posted @ 2013-06-05 16:57 ihge2k 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1845思路:匈牙利算法应用,900ms+险过。(好像直接n/2就行) 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 #define MAXN 5555 8 vector<int>map[MAXN]; 9 int n,m,ans 阅读全文
posted @ 2013-06-05 15:11 ihge2k 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2682思路:一个裸的最小生成树,先打个素数表,然后就是连边了。dfs判断是否连通,连通的话就是kruskal求最小生成树了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 #define MAXN 666 8 struct Edge{ 9 阅读全文
posted @ 2013-06-05 14:41 ihge2k 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 题目链接 :http://acm.hdu.edu.cn/showproblem.php?pid=2128思路:这题判重比较麻烦,我是这样做的:每个状态记录炸弹数目以及爆破点的坐标映射,还要有一个访问数组来标记已经取过的炸弹的位置(下次经过就不能再取了),由于要求时间最短,可以考虑优先队列。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 阅读全文
posted @ 2013-06-05 12:45 ihge2k 阅读(226) 评论(0) 推荐(0) 编辑