#K62127. Final Coordinates After Moves
Final Coordinates After Moves
Final Coordinates After Moves
You are given a starting point with coordinates \( (X, Y) \) and a string \( S \) that represents a series of moves. Each character in \( S \) can be one of the following: U
(up), D
(down), L
(left), or R
(right). Each move updates the coordinates as follows:
U
: Increase \( Y \) by 1D
: Decrease \( Y \) by 1L
: Decrease \( X \) by 1R
: Increase \( X \) by 1
Your task is to compute the final coordinates after performing all the moves in \( S \). The input will be read from standard input and the result should be printed to standard output.
inputFormat
The input consists of two lines:
- The first line contains a non-empty string
S
representing the moves. Each character inS
is eitherU
,D
,L
, orR
. - The second line contains two space-separated integers:
X
andY
, representing the initial coordinates.
outputFormat
Output a single line containing two space-separated integers: the final \( X \) and \( Y \) coordinates after all moves are applied.
## sampleUUDDLRLR
0 0
0 0