Topic Link: Click Open link http://acm.hdu.edu.cn/showproblem.php?pid=1242#include Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. HDU 1242 Rescue bfs+ Priority queue
a line containing "Poor Angel has to stay in the prison all his life."
Sample Input
7 8#.#####.#. A #... R.#... # X.....#..#.##...##...#..............
Sample output
13
Author: Chen, Xue
Source: zoj monthly, October 2003.
Question link: http://acm.zju.edu.cn/onlinejudge/showProblem.do? Problemid = 649
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1242
The Angel is imprisoned .... his ...) to save him, please try the shortest time. There are wall
~~~~
I suddenly found that all the questions for a search were written. Yesterday, we found a BFS problem. HDU is connected to AC and zoj is connected to WA. I have to say that the data on HDU is water ..
I thought about getting up early today and wrote it in both the queue and the monotonous queue. It's 0ms ~~
~~~~
Question link:
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1242
Http://acm.zju.edu.cn/onlinejudge/showProblem.do? Problemid = 649
~~~
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1242
The first idea after reading the question is to take the position of each friend as the starting point BFS out step and take the minimum value. After submission, WA, modify and submit TLE.
This is a multi-to-one search, which in turn is one-to-many. The step required for the first searched friend is the minimum value. After the change, submit again and still wa...
After reading other people's proble
Now let's look at the priority queue again. It's not as confused as it was just getting started! This may be the result of the training!
Come on !!! Priority queue is required!
This question is very simple! Customize priority!
++ ++ ++
========================================================== ========================================================== ===
++ ++ ++
# Include
# Include # Include Using namespace STD;
Int n, m, dir [4] [2] = {,-, 0,-1 };Char s [1, 1010] [2, 1010];
Struct Node{Int X
It should be known to the Chinese.
Train of Thought: This question is quite easy and wrong without careful consideration. Like me, I didn't dare to use the priority queue after I finished learning STL, so I still suffered a loss!
That is, you need to find a from R.
If you simply use a queue
3 3
R ..
# X.
# When a is used, it is easy to make a mistake, and may output 5 or 4. At this time, it is wrong, so we can only use the priority queue for optimization, so that the number of steps is less than
prison all he life."Sample Input7 8#.#####.#.a#. r.#. #x ..... #.##...##...#..............Sample Output13 Test Instructions: The Angels are trapped in prison, his friends want to see him, the prison's topography is complex, including the road (with dots), the wall (marked with a sign), the position of the angel (marked with a), his friend (with R), the prison is also guarded (by X), His friends can only go up and down in four directions, walk to do not spend a unit of time, if meet the guard, e
RescueTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 19478 Accepted Submission (s): 6939Problem DescriptionAngel was caught by the moligpy! He was Vladimir Prison by Moligpy. The prison is described as a n * M (n, M Angel ' s friends want to save Angel. Theirtask Is:approach Angel. We assume that "approach Angel" are to get tothe position where Angel stays. When there's a guard in the grid, we must Killhim (or his?) to move into the grid. We a
stay in the prison all he life."Sample Input7 8#.#####.#.a#. r.#. #x .....#.##...##...#.............. Sample Output13: A is the target location, R is the starting position, through x takes more than 1s time, if not go to the output "Poor ANGEL have to stay in the prison all he life."#include #include#includestring>#include#include#include#include#include#include#include#definePI ACOs (-1.0)#defineMS (a) memset (A,0,sizeof (a))#defineMSP Memset (Mp,0,sizeof (MP))#defineMSV memset (vis,0,sizeof (
Title Address: http://acm.hdu.edu.cn/showproblem.php?pid=1242I did this topic with the bfs+ priority queue. I heard that only using BFS will time out.Because this problem has multiple rescuers, so we start from the rescue of the BFS, find the nearest rescuers is the shortest time.Define a struct, hold coordinates x and Y, and the time it takes to reach the current point (x, y).struct Node { int x, y; int time; friend BOOL operator Notice that the time is low before you dequeue.Focus on
integer, standing for the minimal time needed. If Such a number does no exist, you should output a line containing "Poor ANGEL have to stay in the prison all he life."Sample Input7 8#.#####.#.a#. r.#. #x .....#.##...##...#.............. Sample Output13 authorchen, Xue Sourcezoj Monthly, October 2003 Recommendeddy1#include 2#include 3#include 4#include string>5 using namespacestd;6mapstring,int>m1,m2;7 intMain ()8 {9 intN,ans;Ten stringstr; One while(cin>>N) A { -ans=0; - m1.cle
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1242 Rescue Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 15597 accepted submission (s): 5663 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 Angel's friends want to save Angel. their task is: approach angel. we assume that "approach Angel" is to get to the position wher
Question Link: Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1242
question .
solution :
If there is no special point, it is common BFs.
Because of the intervention of special points, a point may arrive in different ways, so the priority queue is used. For a point, the method used to retrieve the first point must be optimal.
At the same time, the use of priority queue also provides a pruning for the BFS process, because the first arrival is
Hdoj 1242 Rescue (BFS)
Rescue
Http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 1242
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission (s): 18962 Accepted Submission (s): 6771
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
Angel's friends want to save Angel. their task is: approac
1242:zju1015 Fishing Net Chord chart determination time
limit:10 Sec Memory limit:162 MBsubmit:214 solved:81[Submit] [Status] [Discuss]
DescriptionIn a highly informative fishing village, the production and repair of fish nets are done by computers. As we all know, the net is made up of nets (nonsense), the net is composed of something called mesh. If the mesh is small enough, you can catch a lot of fish; if the mesh is too large, the fish wi
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.