码迷,mamicode.com
首页 >  
搜索关键字:bfs 优先队列 stl    ( 13177个结果
7.2.1 生成1~n的排列(全排列)【STL__next_permutation()_的应用】
#include #include #include #include #include #include #include using namespace std;int a[20];void print_permutation(int n, int a[], int cur){ int i...
分类:其他好文   时间:2014-07-09 21:55:48    阅读次数:206
UVA - 1533 Moving Pegs
题意:首先给你空闲的位置,可以跳过几个来吃掉几个,求最短的吃完所有的,且最后一个回到开始指定的位置 思路:BFS+HASH判重,对于每个位置有六个方向,当然有的是不能走的,加上map的判重就可以了 #include #include #include #include #include #include using namespace std; const int MAXN =...
分类:其他好文   时间:2014-07-08 19:29:38    阅读次数:246
hdu:4771Stealing Harry Potter's Precious(bfs + 全排列)
题目:hdu:4771Stealing Harry Potter's Precious 题目大意:给出n* m的矩阵,代表n * m间room,然后每个房间又有脆弱和坚固之分,分别用‘.'和'#‘代替。’@‘代表Dudely所在的起点。 题目说Dudely想要偷Harry的宝物,他知道宝物的位置,但是他的魔法只能穿过脆弱的room。愚蠢的他又想偷完harry所有的宝物,并不在乎如何人出...
分类:其他好文   时间:2014-07-08 18:25:05    阅读次数:256
HDU 4771 Stealing Harry Potter's Precious(BFS + DFS)
HDU 4771 Stealing Harry Potter's Precious 题目链接 题意:给定人的起始位置和k个宝物,求人拿完全部宝物最小的步数 思路:先bfs打出两两之间路径,然后dfs暴力求答案,因为宝物才4个,所以暴力是没问题的 代码: #include #include #include #include using namespace st...
分类:其他好文   时间:2014-07-08 15:58:25    阅读次数:181
hdu 4771 Stealing Harry Potter's Precious(bfs)
题目链接:hdu 4771 Stealing Harry Potter's Precious 题目大意:在一个N*M的银行里,贼的位置在’@‘,现在给出n个宝物的位置,现在贼要将所有的宝物拿到手,问最短的路径,不需要考虑离开。 解题思路:因为宝物最多才4个,加上贼的位置,枚举两两位置,用bfs求两点距离,如果存在两点间不能到达,那么肯定是不能取完所有的宝物。然后枚举取宝物的顺序,维护a...
分类:其他好文   时间:2014-07-08 14:47:59    阅读次数:172
总结STL的通用算法基本形式
stl的通用算法基本有如下四种形式: alg(beg, end, params):使用源输入作为输出 alg(beg, end, dest, params) :使用dest作为输出,需要保证有足够的空间,所以往往使用inserter alg(beg, end, beg2, other params):beg2作为输出,假定beg2开始的范围至少跟beg和end指定的范围一样大。 alg(beg, end, beg2, end2, params):beg2 end2作为输出 举例: 第一种比如: fin...
分类:其他好文   时间:2014-07-08 14:42:03    阅读次数:144
2014 Super Training #6 G Trim the Nails --状态压缩+BFS
原题: ZOJ 3675http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3675由m#include #include #include #include #include using namespace std;#defin...
分类:其他好文   时间:2014-07-08 00:31:26    阅读次数:272
STL中heap算法(堆算法)
??①push_heap算法以下是push_heap算法的实现细节。该函数接收两个迭代器,用来表现一个heap底部容器(vector)的头尾,而且新元素已经插入究竟部的最尾端。template inline void push_heap(RandomAccessIterator first,Rand...
分类:其他好文   时间:2014-07-08 00:22:55    阅读次数:307
UVA 10047 - The Monocycle
题目如下:  Problem A: The Monocycle  A monocycle is a cycle that runs on one wheel and the one we will be considering is a bit more special. It has a solid wheel colored with fiv...
分类:其他好文   时间:2014-07-06 11:49:47    阅读次数:233
POJ 1101 The Game(BFS+判方向)
The Game Description One morning, you wake up and think: "I am such a good programmer. Why not make some money?'' So you decide to write a computer game. The game takes place on a rectangular...
分类:其他好文   时间:2014-07-06 09:02:34    阅读次数:287
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!