房间是N行N列的矩阵,其中0代表空的地板,1代表墙,2代表箱子的起始位置,3代表箱子要被推去的位置,4代表搬运工的起始位置,求最后搬运工推箱子的步数。
问题实质就是五个状态:箱子的位置(bx,by),人的位置(px,py),推箱子的步数。然后用广搜去一一搜索。...
分类:
其他好文 时间:
2014-06-05 11:00:07
阅读次数:
230
题意:求'X'围成的周长
思路:按理说每增加一个就是周长加4,但是要减去重复的地方,这里我是用BFS做的,如果是BFS的模板思路的话是不行的,应该要先取出再标记
#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 30;
struct node {
int x,y;
...
分类:
其他好文 时间:
2014-06-05 06:23:39
阅读次数:
221
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,0...
分类:
其他好文 时间:
2014-06-03 05:30:23
阅读次数:
394
Knight Moves
Time Limit: 1000MS
Memory Limit: 30000K
Total Submissions: 20913
Accepted: 9702
Description
Background
Mr Somuro...
分类:
其他好文 时间:
2014-06-03 04:02:09
阅读次数:
260
BFS+状态压缩,做了很多状态压缩了。今晚把八数码问题给搞定了。 1 #include 2
#include 3 #include 4 #include 5 using namespace std; 6 7 typedef struct node_st
{ 8 int x, y, ...
分类:
其他好文 时间:
2014-06-02 17:14:38
阅读次数:
232
二分图bipartite
使用BFS广度优先判断一个图是否是二分图。基本图操作。
参考
http://www.geeksforgeeks.org/bipartite-graph/
#pragma once
#include
#include
#include
using namespace std;
class CheckwhetheragivengraphisBipa...
分类:
其他好文 时间:
2014-06-01 15:03:24
阅读次数:
288
MinesTime Limit: 10000/5000 MS (Java/Others)Memory
Limit: 65536/65536 K (Java/Others)Total Submission(s): 1110Accepted
Submission(s): 280Problem Descr...
分类:
其他好文 时间:
2014-06-01 11:38:48
阅读次数:
312
课程介绍
这门课程核心内容是算法和数据结构。
具体的算法和数据结构如下:
数据类型:堆栈、队列、背包、并查集、优先队列。
排序:快排、并排、堆排、基数排序
查找:BST、红黑BST、哈希表
图:BFS、DFS、Prim、Kruskai、Dijkstra
字符串:KMP、正则、TST、哈夫曼、LZW
高级:B树、后缀数组、最...
分类:
其他好文 时间:
2014-06-01 10:52:26
阅读次数:
285
http://acm.hdu.edu.cn/showproblem.php?pid=1429
第一次接触搜索+状态压缩 看了大神的题解 勉强把题目弄懂了。
用二进制来表示手头的钥匙有哪些,100表示有第三把钥匙,111表示有第三、二、一把,搜索下一点时,如果该点为钥匙点,则可采用|运算来
模拟拾取,显然0001 | 1000 = 1001,同理,当为相应的门时采用&运算来模拟开启,例...
分类:
其他好文 时间:
2014-06-01 10:35:21
阅读次数:
256
题目大意:
一个农主寻找牛。给出农主的位置n和牛的位置k。农主可以通过n-1或者n+1或者n*2的步伐找牛,问至少多少步才能找到自己的牛。解题思路:
简单的BFS。把农主的每一种可能的步伐通过BFS存到栈中,然后看最少多少步到达K坐标。代码: 1 #include 2 #include 3 ...
分类:
其他好文 时间:
2014-05-31 15:27:27
阅读次数:
252