1130 : Happy RobotTime Limit: 1 Sec Memory Limit: 128 Mb Submitted: 57 Solved: 25
A robot is moving from (0,0) according to a command sequence. Each character in the sequence is command:
- L: turn left
- R: turn right
- F: go forward one step
Interestingly, the command sequence contains some wildcard character “?”. The robot can treat it any one of L, R or F at its own wish, which makes it really happy.
Let (x,y) be the final position of the robot, your task is to find out the minimal/maximal possible value of x and y. Initially the robot is facing east (i.e. facing (1,0) in Cartesian coordinate system). After a left turn it will face north (i.e. facing (0,1)).
There will be at most 1000 test cases. Each case contains a command sequence with no more than 1000 characters.
For each test case, print the case number, followed by minimal/maximal possible x (in this order), then the minimal/maximal possible y.
F?F L?? LFFFRF
Case 1: 1 3 -1 1 Case 2: -1 1 0 2 Case 3: 1 1 3 3