Very simple BFS.
WA reason: or because rqnoj data input with GetChar () seems to be wrong, changed to scanf ("%s"), and then because did not notice starting from 1 ...
scanf ("%s", Map[i]);
Change into
scanf ("%s", map[i][1]);It's AC.
This simple search question can not be once AC is the reflection of the following ...
#define _crt_secure_no_warnings #include
to the edges of the vertex. The vertex VJ adjacent to VI are linked to a single linked list called VI adjacency list. Each node in the adjacency list is composed of two domains: one is the neighboring point Domain (Adjvex), the ordinal number J (can be the subscript of the array unit of vertex VJ in the vertex table) used to store the vertex VJ adjacent to VI; the second is the chain field (next), which links the nodes in the adjacency list. The specific procedures are implemented as follows:
disappear (i.e., in this turn). Well, given the description of a maps, the positions of your tank and the target, how many turns would you take at least to Arrive there?
Input the input consists of several test cases. The first line of all test case contains, integers m and n (2
Output for each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.
Sample Input
3 4
ybeb
EERE
sste
0 0
Sample Output
8Test instructions: How long
the target, how many turns would you take at least to Arrive there? Input
The input consists of several test cases. The first line of all test case contains, integers m and n (2 Output
For each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.Sample Input
3 4YbebEERESste0 0Sample Output
8
title Link:http://poj.org/problem?id=2312 Test Instructions
Calculate the shortest time from ' Y ' to ' t ', where ' S ' and ' R ' cann
target, how many turns would you take at least to Arrive there? Input
The input consists of several test cases. The first line of all test case contains, integers m and n (2 Output
For each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.Sample Input
3 4YbebEERESste0 0Sample Output
8Source
POJ Monthly, Lu Xiao
Test Instructions:Give you a matrix of m rows n columns.Y represents the starting point, and T represents the en
description of a maps, the positions of your tank and the target, how many turns would you take at least to Arrive there?
Input the input consists of several test cases. The first line of all test case contains, integers m and n (2
Output for each test case, please output the turns to least in a separate line. If you can ' t arrive at the target, output "-1" instead.
Sample Input
3 4
ybeb
EERE
sste
0 0
Sample Output
8
Source
POJ Monthly, Lu Xiao
http://blog.csdn.net/furturerock/article/deta
here you should understand, there is no place to move the situation OH ~~~~~~)
Ideas:
Because there are a lot of points can be repeated, so we have to open three-dimensional array vis "" "" "to judge the weight, if one dimension is used to represent X, one dimension is used to represent Y, then the other one to indicate what. Of course, the number of steps to walk, but we do not know the total number of steps we can walk AH ~ so we here to the K to seek redundancy, as long as it is not 0, all i
Daily Punch-In (2/2)
Click to open linkMain topic:
A three-dimensional maze, given the starting point and end point, to find the shortest path.
PS: The length and width of the height are not more than 30
Idea 1:
First think of Dfs, only the first time to write three-dimensional DFS, feeling and two-dimensional nothing different.
#include
The first time I write the experience of the morning, cut a branch first. If the current TOT value has exceeded the previous optimal solution, then pass. Last
The storage structure of graphs
This article focuses on the depth-first search (DFS) and breadth-first search (BFS), so it is no longer to introduce the basic concepts of the graph too much, but to get a general idea of some of the common storage structures in the diagram below.
Adjacency Matrix
The adjacency matrix can be used both to store the graph without direction and to store the graph. In fact, the structure uses a two-dimensional array (adj
Topic links
POJ3278 Topic
Enter two number n,k (0≤\leqn,k≤\leq100000) to find at least a few legal operations from N to K. Legal actions include: + 1,-1, * *. Analysis
Consider each number of 0~100000 as a state, there are 3 ways to transfer the state, only from N start with the BFS expansion, see the expansion to K is the first layer, Time complexity O (3*100000). (similar to the shortest path in the maze)PS: This problem in OJ with g++ submitted on
calculation of time complexity is not very clear. My calculation of the time complexity of this problem is: Obviously the time complexity of the two for Loop is O ((m*n) ^2) =10^4. Then calculate the time complexity of the BFS: obviously each layer has a for loop, the loop volume is 4, the maximum layer is diagonal, 10 layers, so the total complexity of 4^10, in the front of the complexity, obviously timed out. But this is not the case, we can think,
Dating with Girls (2)
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)Total submission (s): 2656 Accepted Submission (s): 741
Problem Description If You had solved the problem Dating with girls (1). I Think you can solve this problem too. This problem was also about dating with girls. Now you are in a maze and the girl you want to date with is also in the maze. If you can find the girl and then you can date with the girl. Else the girl would date with other boy
DFS uses recursive step-by-step heuristics to select the shortest path in all paths
Code:
0 is the road, 1 is the wall
#include
BFS Use the queue one layer at a time to take the shortest
Code:
#include
Print out Path
Input 0 for road, 1 for Wall, 5*5 map//from upper left corner to bottom right #include
Transmission DoorTest instructions: Is given a starting point and an end point, each can go to four directions up to the K-step, each walk spent a second, asked to go to the end of the minimum number of seconds required.Idea: Direct BFS will definitely t, we need to add a few pruning, one is when we go to some point, the point has been reached, and at this time than from the current point of time to go to this point is shorter, then do not go, because
1 1 1 1 1 0 31 1 1 1 1 1 1 11 1 1 1 1 1 1 10 0
Sample Output
4-11320-1
-1
Test instructions: On a n*m map, there are 5 numbers. 0 means not to walk here, 1 means to go here, 3 is the Ant's Cave, 2 is where the ant starts to walk, and 4 says there is food here. An ant to go home, it initially only 6HP, and each step will be reduced by one, when HP is 0 o'clock will die, when it arrives at the food can be restored full hp and the food can be used indefinitely. Ask ants at least how many steps to
UVA-10603-Fill (BFS + priority queue), uva-10603-fillbfs
There are three jugs with a volume of a, B and c liters. (a, B, and c are positive integers not greater than 200 ). the first and the second jug are initially empty, while the third
Is completely filled with water. it is allowed to pour water from one jug into another until either the first one is empty or the second one is full. this operation can be performed med zero, one or more times.
You
Create a program to read and display video files, and use the slider bar to control the playback of video files. A slider is used to control the video playback position, jumping in 10 steps. Another slider to control stop/play/*Create a program to read and display video files, and use the slider bar to control the play
HTML5 video label video and html5 video
At this stage, the most reliable and commonly used way to embed videos in webpages is to use Flash. By using the object and embed tags, you can play swf, flv, and other video files in a browser, but the premise is that the browser must install a third-party plug-in: Adobe Flash P
Attention:
1. About video format, different browser support is not the same, Safari--mp4 CHROME--WEBM Firefox opera--ogv,ie8 or earlier browsers do not support
2. Statement detailed
3. If you want to add a flash plug-in to handle the browser does not support HTML5 playback, you can
Some common property methods and events for the 4.video element API
5. You can use events like ended to add playlists
var
case contains the integers N and M indicate the size of the board. Then goes-N line, each line with M character shows the board. "#" indicates the grass. You can assume this there is at least one grid which are consisting of grass in the board.1 OutputFor each case, output of the case number first, if they can play the more special (Hentai) game (fire all the grass), output The minimal time they need to wait after they set fire, otherwise just output-1. See the sample, input and output for more
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.