POJ 1475 推箱】的更多相关文章

推箱 时限:n.2000MS   内存限制:n.131072K 提交材料共计: 6600   接受: 2263   特别法官 描述 想象一下你站在一个二维迷宫里,由方形细胞组成,它们可能或可能不会充满岩石.你可以在一个台阶上移动北.南.东或西一个单元.这些动作叫做步行.其中一个空单元包含一个盒子,它可以通过站在盒子旁边移动到相邻的自由单元格,然后移动到盒子的方向上.这样的举动叫做推.盒子不能用任何其他方式移动,而不是推,这意味着如果你把它推到角落里,你就再也无法把它从角落里弄出来了. 其中一个空…
bfs是一层层的遍历下去,每多一层即为多走一步,因此只要遇到T就停,此时肯定是最小步数. 所以这两层bfs应为,先对箱子的最少步数进行bfs,从而求出推箱子所用最少步数: 然后箱子bfs内部嵌入人的bfs,从而箱子每走一步,判断一下这个移动能否由人来完成(由箱子的移动倒推人应该在的位置,看这个位置是否合理). 一.http://tech.artyoo.me/?p=282 #include <map> #include <set> #include <queue> #in…
题目链接:http://poj.org/problem?id=1475 一组测试数据: 7 3 ### .T. .S. #B# ... ... ... 结果: //解题思路:先判断盒子的四周是不是有空位,如果有,则判断人是否能到达盒子的那一边,能的话,把盒子推到空位处,然后继续 AC代码: //解题思路:先判断盒子的四周是不是有空位,如果有,则判断人是否能到达盒子的那一边,能的话,把盒子推到空位处,然后继续 #include<iostream> #include<algorithm>…
http://poj.org/problem?id=1475 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=249 Pushing Boxes Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 4662   Accepted: 1608   Special Judge Description Imagine you are standing insid…
题目地址: http://poj.org/problem?id=1475 两重BFS就行了,第一重是搜索箱子,第二重搜索人能不能到达推箱子的地方. AC代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <vector> #inc…
[题目链接] http://poj.org/problem?id=1475 [算法] 双重BFS [代码] #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #incl…
题目大意 人推箱子从起点到终点,要求推箱子的次数最少,并打印出来人移动的路径. 题目分析 对于箱子进行宽搜的同时,要兼顾人是否能够把箱子推到相应的位置 每一次对箱子bfs 然后对人再bfs #include<cstdio>#include<cstring>#include<queue>#include<cmath>#include<iostream>#include<algorithm>#include<string>us…
Imagine you are standing inside a two-dimensional maze composed of square cells which may or may not be filled with rock. You can move north, south, east or west one cell at a step. These moves are called walks.  One of the empty cells contains a box…
Imagine you are standing inside a two-dimensional maze composed of square cells which may or may not be filled with rock. You can move north, south, east or west one cell at a step. These moves are called walks. One of the empty cells contains a box…
OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 3094) 初期: 一.基本算法: 枚举. (POJ 1753,POJ 2965) 贪心(POJ 1328,POJ 2109,POJ 2586) 递归和分治法. 递推. 构造法.(POJ 3295) 模拟法.(POJ 1068,POJ 2632,POJ 1573,POJ 2993,POJ 2996) 二…