摘要: http://codeforces.com/problemset/problem/278/C一开始一门语言都不会的肯定都需要辅导其一门语言,会语言的用并查集处理,一共有几个集合,就辅导几减一的人。#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue& 阅读全文
posted @ 2013-03-30 23:56 aiiYuu 阅读(156) 评论(0) 推荐(0)
摘要: http://codeforces.com/problemset/problem/131/D题目大意:由n个点组成的n条边构成一个环,求n个点与环的距离(环上的点数)。进行两次dfs。第一次dfs找出环上所有的点并标记flag,第二次对所有flag的点进行深搜并标记。#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#incl 阅读全文
posted @ 2013-03-30 12:35 aiiYuu 阅读(214) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1402这道题用FFT解决大数乘法问题,比字符串模拟的大数乘法效率要高,听说还有更加快的数论解法;马上就要学快速福利叶变换了,到时候再补充题解#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#inc 阅读全文
posted @ 2013-03-30 03:01 aiiYuu 阅读(407) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1102Prim算法解决最短路问题#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace std;template <cla 阅读全文
posted @ 2013-03-30 02:32 aiiYuu 阅读(159) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1272题目大意:判断给定的图是否是一棵树。1、判断所有点是否都连通2、每次合并两个点的是否判断这两个点是否已经是在一个集合中了,如果是,那么接下来就不用判断了,因为已经构成了环的条件,已经不可能成为一颗树了。#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include < 阅读全文
posted @ 2013-03-30 02:29 aiiYuu 阅读(123) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1232题目大意:有几个集合,问最少需要连几根线才能把这些集合并为一个集合。N个集合的话就需要N-1条路就行了,简单并查集#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <q 阅读全文
posted @ 2013-03-30 02:25 aiiYuu 阅读(174) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2612走迷宫题目变型,简单bfs#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace std;template <cla 阅读全文
posted @ 2013-03-30 02:21 aiiYuu 阅读(150) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1253题目大意:一个三维的走迷宫游戏。简单bfs#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace std;template 阅读全文
posted @ 2013-03-30 02:17 aiiYuu 阅读(149) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1548题目大意:第i层的电梯只能把人送到第i+K[i]层或第i-K[i]层;给定初始层数和目标层数,求最少雪瑶按几次开关才能从初始位置到目标位置。简单bfs#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath 阅读全文
posted @ 2013-03-30 02:15 aiiYuu 阅读(118) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1242因为有多个营救的人,而只有一个被营救的人,所以以被营救的人为起点进行bfs。(代码中用ma[][]数组进行标记,ma[i][j]表示的是起始坐标(sx,sy)到(i,j)的最短距离)#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#i 阅读全文
posted @ 2013-03-30 02:10 aiiYuu 阅读(150) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2544不解释,最短路裸题#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace std;template <class T 阅读全文
posted @ 2013-03-30 02:06 aiiYuu 阅读(113) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3274题目大意:在一棵树中找一棵包含所有我要的节点的最小生成子树。直接搜索#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <queue>using namespace 阅读全文
posted @ 2013-03-30 02:03 aiiYuu 阅读(123) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2660题目大意:n个珠子里面找k个珠子,使得价值最大但重量不超过某一限定值。直接对要不要第i颗珠子进行dfs,搜索过程中注意剪枝。#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include 阅读全文
posted @ 2013-03-30 01:57 aiiYuu 阅读(118) 评论(0) 推荐(0)