C. The Ending Point

C. The Ending Point
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Tahhan was hungry, so AbuTahun decided to show him the way to Rakan's cafeteria.
AbuTahun gave Tahhan a string consisting only of the letters ('L','R','U','D'), denotes the path to the cafeteria.
  • U — move from (x,y) to (x,y+1). 
  • D — move from (x,y) to (x,y1). 
  • L — move from (x,y) to (x1,y). 
  • R — move from (x,y) to (x+1,y). 
Tahhan located at point (x,y), and he wants to go to the cafeteria.
Can you tell Tahhan where Rakan's cafeteria is?
Input
first line of input consists of two integers x,y (1x,y100) , denotes the starting point.
the second line consists of string s (1|s|100) denotes the path to the cafeteria .
Output
print two integers which denotes the ending point.
*Note* the answer could contains a negative integer.
Example
input
Copy
5 3
UUUDLRLRLRR
output
Copy
6 5

Comments

Popular posts from this blog

How to pass parameters in webhook?

Access and modify all the resources of our Wiki.js using WikiJS API

Fahrenheit to Celsius