#C7155. Robot Path Finder
Robot Path Finder
Robot Path Finder
You are given a target point \((x, y)\) on a 2D plane and a string of commands. The robot starts at the origin \((0,0)\) and follows the commands in order. Each command is one of the following characters:
- U for moving up (\(y+1\))
- D for moving down (\(y-1\))
- L for moving left (\(x-1\))
- R for moving right (\(x+1\))
The robot processes each command sequentially. If at any point during the movement the position of the robot becomes exactly \((x, y)\), the robot immediately stops and the answer is "YES". If the end of the command string is reached without ever landing on \((x, y)\), output "NO".
Your task is to determine whether the robot can reach the specified target point.
inputFormat
Input is read from standard input. The first line contains two space-separated integers \(x\) and \(y\) representing the target coordinates. The second line contains a non-empty string of characters representing the commands. The command string only includes the characters 'U', 'D', 'L', and 'R'.
outputFormat
Output "YES" (without quotes) if the robot reaches the target point \((x, y)\) during its movement, otherwise output "NO".
## sample2 3
UUURRR
YES
</p>