#C4412. Robot Final Position
Robot Final Position
Robot Final Position
Given the initial coordinates\( (x,y) \) of a robot and a string of commands, determine its final position on the Cartesian plane. The robot follows the commands one-by-one where each command is one of the following:
U
: move up (i.e. increase the \( y \)-coordinate by 1)D
: move down (i.e. decrease the \( y \)-coordinate by 1)L
: move left (i.e. decrease the \( x \)-coordinate by 1)R
: move right (i.e. increase the \( x \)-coordinate by 1)
You are required to read the input from stdin and print the answer to stdout. The first line of input contains two integers representing the initial coordinates \( x \) and \( y \). The second line contains a string representing the sequence of commands. Your task is to compute and print the final coordinates after executing all the given commands.
Note: It is possible that the command string is empty, in which case the robot remains at its starting position.
inputFormat
The input consists of two lines:
- The first line contains two space-separated integers \( x \) and \( y \), representing the initial coordinates.
- The second line contains a string \( s \) where each character is one of
U
,D
,L
, orR
. This string represents the movement commands.
outputFormat
Output a single line containing two space-separated integers representing the final \( x \) and \( y \) coordinates of the robot after executing all the commands.
## sample1 2
1 2