algorithm_搜索
文章平均质量分 85
theArcticOcean
Website: https://www.weiy.city
Wechat Subscription Account: 胡桃小院
展开
-
hdu 1242 Rescue(BFS+优先队列)
起初只是用BFS做,但后来发现问题太多了,起点是一个,但可能有多个士兵,要找到最小的距离即要求每一个子问题的结果都是最小值。用深度优先搜索自然不能每次都返回较小值。而广度优先搜索就像使用了分身术一样,4个方向都有friend去找angel,各自返回自己的最小值,所以思路就是BFS+优先队列。 #include #include #include #include using namespac原创 2015-05-28 17:06:07 · 653 阅读 · 0 评论 -
codeforces 412D. Giving Awards (dfs)
http://codeforces.com/problemset/problem/412/D Description The employees of the R1 company often spend time together: they watch football, they go camping, they solve contests. So, it's no big原创 2015-11-25 21:33:55 · 684 阅读 · 0 评论 -
hdu 1111 Secret Code(复数·展开·深搜·输出)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1111 Secret Code Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 740 Accepted Submission原创 2015-09-05 10:08:23 · 1331 阅读 · 0 评论 -
hdu 2102 A计划(bfs)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2102 A计划 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13158 Accepted Submission(s): 3原创 2015-08-06 18:28:27 · 901 阅读 · 2 评论 -
poj 1426 Find The Multiple(dfs || 二进制枚举)
题目:http://poj.org/problem?id=1426 大意是:给定一个数字n,求出数字m,其中m是n的倍数,且m是只由0,1构成的十进制数。 Sample Input 2 6 19 0 Sample Output 10 100100100100100100 111111111111111111 经典的深搜,开始我一直往数论方向想呢···使用单纯的枚举肯定是要超时的原创 2015-08-06 19:52:36 · 910 阅读 · 0 评论 -
hdu Tempter of the Bone(DFS + 枝减)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1010 大意:在一个坐标内,给定起点和终点,问能否恰好在t时刻到达终点。 刚好到达问题,嘿嘿,有意思。不考虑广搜了,用深搜: 因为有标记tag,及时地跳出不做无用功,用奇偶枝减提高效率。看看这里的奇偶枝减是怎么回事儿: 代码: #include #include #include #inc原创 2015-08-06 21:44:47 · 499 阅读 · 0 评论 -
hdu 1312 Red and Black(DFS)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1312 大意:一个人只能在'.'上移动,问@所在地的人能到多少个'.'。 Sample Input 6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######.原创 2015-08-06 22:22:11 · 437 阅读 · 0 评论 -
poj 1321 棋盘问题 (dfs)
题目:http://poj.org/problem?id=1321 棋盘问题 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28409 Accepted: 14048 Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋原创 2015-08-06 18:54:29 · 502 阅读 · 0 评论 -
hdu 5339 Untitled(枚举 || DFS)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5339 大意:在所有的给定的一定数目的数字中选择最少的数字让他们满足:a%b1%b2%……%bn=0。输出最小的n. 暴力枚举和DFS的本质都是一样的: #include #include #include #include using namespace std; const int INF=1e原创 2015-08-06 23:35:53 · 488 阅读 · 0 评论 -
hdu 1241 Oil Deposits(经典dfs)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1241 大意:寻找一块区域中有多少的‘@’域,左右上下还有四个斜45度的相邻点都算作连起来的。 Sample Input 1 1 * 3 5 *@*@* **@** *@*@* 1 8 @@****@* 5 5 ****@ *@@*@ *@**@ @@@*@ @@**@ 0 0原创 2015-08-06 20:55:14 · 536 阅读 · 0 评论 -
hdu 1372 Knight Moves(经典BFS)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1372 大意:至少要用多少步,骑士才能从给定位置到达另一个位置。 Sample Input e2 e4 a1 b2 b2 c3 a1 h8 a1 h7 h8 a1 b1 c3 f6 f6 Sample Output To get from e2 to e4 t原创 2015-08-06 20:38:51 · 584 阅读 · 0 评论 -
poj 3126 Prime Path(bfs)
题目:http://poj.org/problem?id=3126 大意:给出两个素数,至少求出要经过多少步能够由A变成B,否则输出:Impossible. 要求最少的步骤,联想到用BFS。 #include #include #include #include using namespace std; bool vis[10005]; int number1,number2;原创 2015-08-06 20:08:22 · 567 阅读 · 0 评论 -
poj 3278 Catch That Cow(经典bfs)
题目:http://poj.org/problem?id=3278 Language: Default Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 62063 Accepted: 19415 Descri原创 2015-08-30 20:13:44 · 607 阅读 · 0 评论 -
poj 1699 Best Sequence(dfs+A(n,n))
题目:http://poj.org/problem?id=1699 Best Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5467 Accepted: 2146 Description The twenty-first cen原创 2015-08-12 20:31:07 · 672 阅读 · 0 评论 -
hdu 4462 Scaring the Birds(暴力,细读)
题意:http://acm.hdu.edu.cn/showproblem.php?pid=4462 我想说,这道题不是考验数据结构或是神马复杂的算法,就是考验人的阅读能力和思维的缜密。有两点:第一点都能看出来,当k=0时不能保护已有的庄稼;第二点,当k=n*n时,即所有的点都是没有庄稼的,直接输出0. #include #include #include using namespace原创 2015-07-04 21:15:50 · 682 阅读 · 0 评论 -
poj 1088 滑雪(dfs记忆化搜索)
题目:http://poj.org/problem?id=1088 滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 84530 Accepted: 31645 Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是原创 2015-08-29 21:55:26 · 642 阅读 · 0 评论