Sample Input
3 1 N 3 3
1 1 WL NR *
1 2 WLF NR ER *
1 3 NL ER *
2 1 SL WR NF *
2 2 SL WF ELF *
2 3 SFR EL *
0
Sample Output
(3,1) (2,1) (2,2) (2,3) (1,3) (+) (2,1)
(2,2) (1,3) (2,3) (3,3)
Analysis
The main idea of the topic is to enter the starting point, leaving the starting point and the end point, to find a shortest.
At each coordinate, there is the direction at which the coordinates are entered, that is news. News shows on, right, left, down, LFR, respectively, left, straight, right. For example, you input, 1 1 NR EL, corresponding to the figure (1, 1) coordinate point, said: When you enter (at the time) of the turn of N, that is, when you go upward, then you can only r, that is, turn right; When you enter the direction of E, that is left, then you can only L, then left Combined with graphic understanding!
Introduction to the algorithm classic sixth chapter example 6-14 Abbott Revenge (Abbott's Revenge) BFS algorithm implementation