hdu--1072--Nightmare(bfs回溯)】的更多相关文章

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1072 Description Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes.…
http://acm.hdu.edu.cn/showproblem.php?pid=1072 遇到Bomb-Reset-Equipment的时候除了时间恢复之外,必须把这个点做标记不能再走,不然可能造成死循环,也得不到最优解. #include <cstdio> #include <cstring> #include <queue> using namespace std; struct point { int x,y,time,step; }; point s; in…
Description Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial exploding time of the bomb is set to 6…
题目链接 Problem Description Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial exploding time of the bom…
Nightmare Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14260    Accepted Submission(s): 6930 Problem Description Ignatius had a nightmare last night. He found himself in a labyrinth with a ti…
HDU 3085 Nightmare Ⅱ(噩梦 Ⅱ) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   Problem Description - 题目描述 Last night, little erriyue had a horrible nightmare. He dreamed that he and his girl friend were trapped in a…
[hdu P3085] Nightmare Ⅱ Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2885 Accepted Submission(s): 806 Problem DescriptionLast night, little erriyue had a horrible nightmare. He dreamed that he a…
HDU - 3085 Nightmare Ⅱ 双向BFS,建立两个队列,让男孩女孩一起走 鬼的位置用曼哈顿距离判断一下,如果该位置与鬼的曼哈顿距离小于等于当前轮数的两倍,则已经被鬼覆盖 #include <cstdio> #include <queue> #include <algorithm> #include <cmath> #include <cctype> #include <cstring> using namespace…
典型的倒水问题: 即把两个水杯的每种状态视为bfs图中的点,如果两种状态可以转化,即可认为二者之间可以连一条边. 有3种倒水的方法,对应2个杯子,共有6种可能的状态转移方式.即相当于图中想走的方法有6种,依次枚举即可. 用一个二维数组标记状态,以免重复. 难点在于输出路径,即bfs回溯. 我的处理方法是,在bfs的队列基础上,用一个vector保存每一个可能的状态,即每个状态对应一个编号.同时结构体中不仅保存每个状态的信息,而且还要保存每个状态的对应编号和上一个状态的对应编号. 那么,当bfs到…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1072 题目大意:走迷宫.走到装置点重置时间,到达任一点时的时间不能为0,可以走重复路,求出迷宫最短时间. 解题思路: vis的第三维标记一下到这个格子的时间. 尽管可以格子可以重复走,但在相同时间到这个格子是没有意义的. 小心一下时间不能为0的问题就行了. #include "cstdio" #include "queue" #include "cstrin…