|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||5||0||0||0.000%|
Driving a rover on Mars while sitting on Earth isn’t all that easy. It takes a while for signals to be delivered up there, and feedback isn’t all that instantaneous, either. Furthermore, the rover is a rather delicate and expensive vehicle. As a result, it drives rather slowly, and has to be given very precise instructions on which motors to use at what time. Here, we will look at a very much simplified model of driving a rover.
For our model, the rover will have the commands FORWARD, BACKWARD, FASTER, SLOWER, STOP, RIGHT, LEFT, NOOP. They work as follows:
The commands FORWARD, BACKWARD, RIGHT, and LEFT only take effect if the rover is stopped at the time. If it is moving already, the command is ignored. Similarly, FASTER and SLOWER only take effect if the rover is rolling forward; otherwise, they are ignored.
You will be given a sequence of n ≤ 1000 commands, for n consecutive seconds. Your goal is to figure out the final location of the rover at the end of those n seconds, assuming the rover started at the point (0, 0) facing up. x coordinates increase from left to right, and y coordinates increase from bottom to top.
The first line contains the number K of data sets. This is followed by K data sets, each of the following form:
The first line contains the number of commands/seconds n. This is followed by n lines, each containing one of the above 8 commands, all in uppercase.
For each data set, output “Data Set x:” on a line by itself, where x is its number. Then output the (integer) coordinates at which the rover ends up, in the order x y. Each data set should be followed by a blank line.
1 6 FORWARD RIGHT STOP RIGHT FORWARD FASTER
Data Set 1: 3 2