HDU1242 Rescue(BFS+优先队列)】的更多相关文章

Rescue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20938    Accepted Submission(s): 7486 Problem Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is d…
直接把Angle的位置作为起点,广度优先搜索即可,这题不是步数最少,而是time最少,就把以time作为衡量标准,加入优先队列,队首就是当前time最少的.遇到Angle的朋友就退出.只需15ms AC代码: #include<cstdio> #include<cstring> #include<queue> using namespace std; const int maxn=202; int d[maxn][maxn]; int n,m; char G[maxn]…
http://acm.hdu.edu.cn/showproblem.php?pid=1242 题意:     Angel被传说中神秘的邪恶的Moligpy人抓住了!他被关在一个迷宫中.迷宫的长.宽不超过200. 迷宫中有不可以越过的墙以及监狱的看守.  Angel的朋友带了一些救援队来到了迷宫中.他们的任务是:接近Angel.我们假设接近Angel就是到达Angel所在的位置. 假设移动需要1单位时间,杀死一个看守也需要1单位时间.到达一个格子以后,如果该格子有看守,则一定要杀死.交给你的任务是…
Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison. Angel's friends want to save Angel. Their task is: approach Angel…
Rescue Time Limit: 2 Seconds      Memory Limit: 65536 KB Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison. Angel's friends want…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1242 题目描述: Problem Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison…
思路 : 优先队列 每次都取最小的时间,遇到了终点直接就输出 #include<iostream> #include<queue> #include<cstring> using namespace std; ; int n,m,sa,ea,sr,er; char arr[N][N]; }; struct stu{ int a,b; int time; bool friend operator <(const stu &a,const stu &b…
题目链接:Rescue 进度落下的太多了,哎╮(╯▽╰)╭,渣渣我总是埋怨进度比别人慢...为什么不试着改变一下捏.... 開始以为是水题,想敲一下练手的,后来发现并非一个简单的搜索题,BFS做肯定出事...后来发现题目里面也有坑 题意是从r到a的最短距离,"."相当时间单位1,"x"相当时间单位2,求最短时间 HDU 搜索课件上说,这题和HDU1010相似,刚開始并没有认为像剪枝,就改用  双向BFS   0ms  一Y,爽! 网上查了一下,神牛们居然用BFS+优…
题目链接 题意 : 求从1城市到n城市的最短路.但是每条路有两个属性,一个是路长,一个是花费.要求在花费为K内,找到最短路. 思路 :这个题好像有很多种做法,我用了BFS+优先队列.崔老师真是千年不变的SPFA啊,链接.还有一个神用了好几种方法分析,链接 . 用优先队列控制长度,保证每次加的都是最短的,每次从队列中取元素,沿着取出来的点往下找,如果费用比K少再加入队列,否则不加,这样可以省时间. #include <stdio.h> #include <string.h> #inc…
找到朋友的最短时间 Sample Input7 8#.#####. //#不能走 a起点 x守卫 r朋友#.a#..r. //r可能不止一个#..#x.....#..#.##...##...#.............. Sample Output13 bfs+优先队列 #include <iostream> #include <cstring> #include <cstdio> #include <queue> using namespace std;…