#K58677. Move Robot Coordinates
Move Robot Coordinates
Move Robot Coordinates
This problem involves simulating the movement of a robot on a 2D plane. The robot starts at the origin (0, 0) and follows a series of instructions. Each character in the instruction string can be:
U
for up (increases the y-coordinate by 1)D
for down (decreases the y-coordinate by 1)R
for right (increases the x-coordinate by 1)
The final coordinates (x, y) are computed as follows:
\( x = \#R \quad and \quad y = \#U - \#D \)
Your task is to read an input containing multiple test cases, process each instruction string, and output the final coordinates for each test case.
inputFormat
The first line of input contains a single integer T representing the number of test cases. The following T lines each contain a non-negative string of characters, each character being either U
, D
, or R
. Note that the string may be empty.
outputFormat
For each test case, output a single line containing two integers separated by a space, representing the final x and y coordinates of the robot after processing the instruction string.
## sample1
URR
2 1