#C6225. Robot Movement Simulator
Robot Movement Simulator
Robot Movement Simulator
In this problem, you must simulate the movement of a robot on a two-dimensional plane. The robot starts at the origin \( (0, 0) \) and executes a sequence of commands. Each command instructs the robot to move one unit in one of four directions: 'U' for up, 'D' for down, 'L' for left, and 'R' for right.
You are given an integer \( n \) representing the number of commands, followed by a string of \( n \) characters. Your task is to compute the final coordinates \( (x, y) \) of the robot after processing all the commands.
The movement can be described by the following updates:
- \( U: (x, y+1) \)
- \( D: (x, y-1) \)
- \( L: (x-1, y) \)
- \( R: (x+1, y) \)
inputFormat
The input consists of two lines:
- The first line contains an integer \( n \) indicating the number of commands.
- The second line contains a string of \( n \) characters. Each character is one of 'U', 'D', 'L', or 'R'.
outputFormat
Output the final coordinates of the robot as two space-separated integers: the \( x \)-coordinate followed by the \( y \)-coordinate.
## sample10
UUDDLLRRLR
0 0
</p>