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. Angel's friends want to save Angel. Their task is: approa…
题目链接:hdu 1242 这题也是迷宫类搜索,题意说的是 'a' 表示被拯救的人,'r' 表示搜救者(注意可能有多个),'.' 表示道路(耗费一单位时间通过),'#' 表示墙壁,'x' 代表警卫(耗费两个单位时间通过),然后求出 'r' 能找到 'a' 的最短时间,找不到输出 "…………"(竟然在这里也 wa 了一发 -.-||).很明显是广搜了,因为 'r' 可能有多个,所以我们反过来从 'a' 开始搜,每次搜到 'r' 都更新最小时间值(很重要的一个转换!).可是这题因为通过 '…
Rescue Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 14   Accepted Submission(s) : 7 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Angel was caught by the MOLIGPY…
题目链接: 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…
http://acm.hdu.edu.cn/showproblem.php?pid=1242 感觉题目没有表述清楚,angel的朋友应该不一定只有一个,那么正解就是a去搜索r,再用普通的bfs就能过了. 但是别人说要用优先队列来保证时间最优,我倒是没明白,步数最优跟时间最优不是等价的吗?就算士兵要花费额外时间,可是既然先到了目标点那时间不也一定是最小的? 当然用优先队列+ a去搜索r是最稳妥的. #include <cstdio> #include <cstring> #inclu…
题目 /******************以下思路来自百度菜鸟的程序人生*********************/ bfs即可,可能有多个’r’,而’a’只有一个,从’a’开始搜,找到的第一个’r’即为所求 需要注意的是这题宽搜时存在障碍物,遇到’x’点是,时间+2,如果用普通的队列就 并不能保证每次出队的是时间最小的元素,所以要用优先队列,第一次用优先队列,还不熟练哇 优先队列(priority_queue)的基本操作: empty(); 队列为空返回1 pop();   出队 push(…
此刻再看优先队列,不像刚接触时的那般迷茫!这也许就是集训的成果吧! 加油!!!优先队列必须要搞定的! 这道题意很简单!自己定义优先级别! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ =================================================================================== +++++++++++++…
http://acm.hdu.edu.cn/showproblem.php?pid=1242 问题:牢房里有墙(#),警卫(x)和道路( . ),天使被关在牢房里位置为a,你的位置在r处,杀死一个警卫要一秒钟,每走一步要一秒钟,求最短时间救出天使,不能救出则输出:Poor ANGEL has to stay in the prison all his life.  求最短路径,果断广搜BFS 限制及剪枝: 1.墙不能走,不能离开牢房范围 2.杀死一个警卫要多花一秒钟 3.当前步骤大于等于最短时间…
题目来源: 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 pris…
Rescue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24205    Accepted Submission(s): 8537 Problem Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is d…