摘要: BFS+标记最小转弯次数http://blog.csdn.net/zhuhuangjian/article/details/8262561http://www.cnblogs.com/g0feng/archive/2012/09/02/2667644.html这题的解法就是对四个方向 BFS, 但不是一步一步 , 也就是搜一个方向的时候一直搜索到沿这个方向能走到的尽头 ,这样搜的话 , 能够保证搜过的路径的转弯次数都是最小的#include<stdio.h>#include<queue>#include<string.h> #include<queue 阅读全文
posted @ 2013-04-14 15:38 宛如 阅读(164) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#define MAX_ 100000;char map[100][100];typedef struct { int x ,y ,time ,front; }point;int dir[4][2] = {-1,0,0,1,1,0,0,-1} ,mintime[100][100];int n , m ,I ,J;point arr[1000000];void bfs (){ while (I != J)//队列不为空 { point head = arr[I++]; fo... 阅读全文
posted @ 2013-04-14 15:22 宛如 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 广搜的全称为广度优先搜索,会用到队列结构中增加char类型的key[26],会MLE(超内存);所以用二进制来表示手头的钥匙100表示有第3把,111表示有第3,2,1把钥匙,如果该点为钥匙点,则可采用|运算来模拟拾取,显然0001|1000 = 1001,同理,当为相应的门时采用&运算来模拟开启,例如1101 & 0001 = 0001(即可以打开'A'门)#include<stdio.h>#include<queue>using namespace std;//定义队列一定要写这个 int n,m,t;char map[21][21] 阅读全文
posted @ 2013-04-14 15:10 宛如 阅读(142) 评论(0) 推荐(0) 编辑