Home > Back-end >  Please leaders to help (' - omega - `)! This topic how to programming
Please leaders to help (' - omega - `)! This topic how to programming

Time:03-26

[problem description] as shown in the following figure (a) tiger qiaohu robots there are several kinds of working mode, including walking programming model with simple programming function, can receive advance (F), back (B), turn left (L) and right (R), four kinds of instruction, input a series of instructions, and then press OK key, tiger qiaohu robot is shown in figure (B) the map from the starting position to perform the corresponding action instruction sequences, assume that the robot's initial is toward the north, input map (including the original position of the tiger qiaohu) and sequences of instructions, the final location of the output tiger qiaohu and front,
[form] input input file contains multiple test data, each test data contains three parts, part 1 a line, as the two integers, M, N (separated by Spaces), 2 & lt; M, N<=20, said the row and column of the map (line and column number starting from 1 meter). Part 2 is a line for a line of string, contains only F, B, L, R four characters, says tiger qiaohu robot receives instruction sequence, length of not more than 100 characters; Part 3 M lines, each row have N characters, these characters can be
The dot ". ", said can pass box;
Character "S", said the starting position of the tiger qiaohu robot (map of test data to ensure there is only one "S")
Characters "*", says obstacles, impassable,
Input file "0 0", the last behavior represents the end of the input,
Note: 1) if the received instructions for 'B' (back), is back in the opposite direction to the current heading a box, but towards the same;
2) tiger qiaohu robots can't out of the border, also cannot enter the obstacles of the lattice, so if you execute a command after the border or has entered the obstacles of the lattice, this order is invalid, skip this instruction, continue to implement the next instruction,
[form] output for each test data, the output of a line, for the two integers and one character at a time, separated by a space, finally said tiger qiaohu robot position (i.e., line and column number) and front, note: n, e, s, w, respectively was toward the north, east, south, west,
[sample input]
5 5
FFLRBFLLRBLLF
*... *
. *...
. S..
. *. *.
. *..
0 0
[sample output]
1 4 e
  • Related