hdoj 1072 Nightmare】的更多相关文章

Nightmare Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8480    Accepted Submission(s): 4069 Problem Description Ignatius had a nightmare last night. He found himself in a labyrinth with a tim…
bfs,使用ttl进行剪枝. #include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std; #define MAXNUM 10 int map[MAXNUM][MAXNUM], ttls[MAXNUM][MAXNUM], n, m; ][] = {{-,},{,},{,-},{,}}; typedef struct node_st…
题目: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.…
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…
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…
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…
题目传送门 题意:一个人去救女朋友,两个人都在运动,还有鬼在"扩散",问最少几秒救到女朋友 分析:开两个队列来表示两个人走过的路,一个人走到的地方另一个人已经vis了,那么就是相遇了,鬼就用曼哈顿距离判断. #include <bits/stdc++.h> using namespace std; const int N = 8e2 + 5; char maze[N][N]; int n, m; bool vis[N][N][2]; int dx[4] = {-1, 1,…
上一篇讲了DFS,那么与之相应的就是BFS.也就是 宽度优先遍历,又称广度优先搜索算法. 首先,让我们回顾一下什么是"深度": 更学术点的说法,能够看做"单位距离下,离起始状态的长度" 那么广度是什么呢? 个人认为,能够这么归纳: 何为广度? 能够看做"距离初始状态距离相等的结点"的集合 那么BFS的核心思想就是:从初始结点開始,搜索生成第一层结点.检查目标结点是否在这些结点中,若没有,再将全部第一层的结点逐一进行搜索,得到第二层结点,并逐一检查…
之前的BFS都是需要一个标记数组,但这个题不一样,因为可能一个格子不止走一次. 那么我们就要寻找新的入队条件:left比上次经过的时候大才入队(left表示上次经过该点时剩余的时间). 为什么呢?我们重复走过一个点只有一个可能,那就是为了去取那个,所以如果取完后再回头经过这个点的时候剩余时间变多了,我们的目的就达到了. left数组初值为0 优化: 重置时间的装置最多取一次就够了,所以可以再开一个标记数组vis记录装置是否用过. //#define LOCAL #include <cstdio>…