/* Reading this question from yesterday afternoon until now, I have done a similar continuous reading problem, which is similar to this question,I wrote it according to that idea. I found it step by step. I was dizzy and failed to write BFS into the storm. In the morning, ask the cool about BFs.Do not search for the number of steps. Search for the number of straight lines directly. It means a road goes to the head and does not hit the south wall.^_^ )
| Help center | welcome, liang530, office call: 0738-8371676
HomepageYou are welcome to visit the Program Design Competition website of Hunan Institute of humanities and technology. We are striving to do better!
System Homepage| Help |Full-text search
Discussion board| Forum list
Question list| Upload questions| Submission status
The competition is over|Reserve a competition |Current competition
User ranking| Modify personal information| User Registration
Data Structure: Figure 2 (
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
disappear (I. E ., in this turn ). well, given the description of a map, the positions of your tank and the target, how many turns will you take at least to arrive there?
Input The input consists of several test cases. the first line of each test case contains two integers m and n (2 Output For each test case, please output the turns you take at least in a separate line. If you can't arrive at the target, output "-1" instead.
Sample Input
3 4YBEBEERESSTE0 0
Sample output
8
Source Poj mon
target statuses of the magic board, please give the transformation steps from the initial state to the smallest number of changes in the object state. If there are multiple conversion schemes, take the smallest Lexicographic Order.
Each group of input test data includes two rows, representing the initial and object states of the magic board.
Output converts the output of each group of test data to meet the requirements of the question.
Sample Input
12345678172453681234567882754631
Sample output
Question: Give a number N, N> = 0, n
Resolution:
First, the analysis shows that because it is the number of digits plus, rather than the number, it is impossible to blindly append the number of digits because it must be processed!
Second, the M number can contain an infinite number based on the meaning of the question.
So here we need a solution, that is, the remainder. In fact, there can be only N results (if 0) for any number-to-N remainder operation ). And there is such a formula. If
prison all his life."
Sample Input
7 8
#.#####.
#. A #... R.
#... # X...
..#..#.#
#...##..
.#......
........
Sample output
13
Resolution:
In order to ensure that the BFS tree is stretched out at an equal distance, this is not an equal distance, so some processing is required.
1. My method is to find the angel, compare the time to the lower size, and finally output the smallest value. Optimization is required. In this case, it will be TLE's. I
1 2
1 1 2
0 3 5
Input description:
A total of four meteors will fall into the Overlord. The coordinates of the landing points are (0, 0), (2, 1), (1, 1)
And (0, 3), the time is 2, 2, 5. Sample output5
Output description:
If we observe the overlord at t = 5, we can find that the security grid closest to Brother Furong is
() -- But as early as the second meteor landed, Brother Furong ran directly to the () Route and was blocked.
The second safe grid closest to Brother Furong is (), but it is the
Huadian North Wind BlowsKey laboratory of cognitive computing and application, Tianjin UniversityLast Modification Date: 2015/8/22There are adjacency matrices, adjacency linked lists, sparse matrices and so on for the storage of the graph.The non-direction graph mainly includes the two sides content, the graph traverse and seeks the unicom component.One, the traversal of the graph without directionThere are two ways to traverse a non-graph-breadth-first search (
A graph is a flexible data structure that is typically used as a model to define relationships or connections between objects. Objects are represented by vertices ( V ), and relationships or associations between objects are represented by edges () of the graph E .Graphs can be divided into the direction of the graph and the non-direction diagram, generally used G=(V,E) to represent the diagram. An adjacency matrix or adjacency table is often used to describe a graph.In the basic algorithm of gra
HDU 1728
Background: WA 29 times, finally, with the help of other people's ideas.
The first idea is to store each position of the visit array as the minimum number of turns required to reach the current coordinate point, and finally to the minimum number of turns to reach that point for each of the traversed points. The minimum turning points are also handed down to a minimum turning points .... This layer is deferred until the end point.
The second way: in the ordinary case of the
1.BFS is used to search the shortest path of the solution is more appropriate, such as the minimum number of steps to solve the solution, the minimum number of exchanges, because the solution encountered in the BFS search process must be closest to the root, so encountered a solution, must be the optimal solution, at this time the search algorithm can terminate. DFS is not appropriate at this time, because
containing "Poor ANGEL have to stay in the prison all he life."
Sample Input
7 8#.#####.#.a#. R.#.. #x ..... #.. #.##...##...#..............
Sample Output
13
The problem is that angle was caught and her friend went to save her. And X is a hindrance to his enemies, but Angle's friends are strong enough to destroy all enemies, but while destroying the enemy,
He's going to take 1 more seconds to find out the shortest amount of time he needs to save angle.
This problem uses
/*
Question:
There are some aliens in the rectangle where they are located. Some of them can be divided into many teams and asked what these teams need in total.
Minimum number of mobile steps
Analysis:
Because it can be divided into many teams, it can be seen that the Minimum Spanning Tree is obtained from the starting point (in fact, there is no starting point, MST is sure
Including the start point), so the problem is converted to the Minimum Spanning Tree. How to process the
Question:
Give N and M numbers (one digit)
The multiples of the minimum N value do not include the M number and output-1 does not exist.
Ideas:
First, it is possible that this number is too long, so it cannot be solved by brute force.
Therefore, this question should be a BFS
Why can I use the remainder?
For the current remainder into the queue, it must be the minimum value of the remainder
Next, how should we add things that meet the conditions?
There
Question link:
Question:
Given n words.
There are m Replacement Methods below, and the words on the Left can become words on the right.
After any replacement, the number of the last letter R is the minimum, and the total length of the word is the minimum if R is the least.
Number and Word Length of the output letter R.
Ideas:
If a word has two parameters, M replacement rules can be used as Directed Graphs of M points.
The end point of some words will be determined, so we will reverse the
# Include # Include # Include # Include # Include Using namespace STD;Typedef vector Void BFS (Graph P){Bool visited [P. Size ()];For (INT I = 0; I! = (INT) p. Size (); I ++){Visited [I] = false;}Queue If (P. Empty ()){Return;}Que. Push (0 );While (! Que. Empty ()){Int visiting_point = que. Front ();Que. Pop ();If (! Visited [visiting_point]){Cout Visited [visiting_point] = true;For (list ITER! = P [visiting_point]. End (); ITER ++){Que. Push (* ITER
2014 Beijing Network Competition 09, HDU 5040
This online competition is really miserable, and it's strange that I didn't think about the problem strategy. After I cut the water questions such as the sign-in question, I went to see the 06 frog question. As a result, t_t was thrown into the trap by the dead frog... After four hours, I didn't figure it out... I kneel down to the frog... At that time, I was prepared to answer this question, and the question description was also very painful. Some
2014 ACM/ICPC Asia Regional Beijing online
For N * n Matrices
M start point, t end point
Cameras with starting directions north N, East e, South S, and West W can be detected in the range of self-directed 1 grid and Rotate 90 ° clockwise every 1 second.
If there is a lamp in front or a place on your own, it takes 3 seconds to move it, or wait for a second to move it.
BFS priority queue
Enable the three-dimensional hash array to determine the weight.
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.