#K80352. Robot Navigation Challenge

    ID: 35511 Type: Default 1000ms 256MiB

Robot Navigation Challenge

Robot Navigation Challenge

You are given a robot located at the origin (0, 0) on a 10x10 grid (with coordinates ranging from 0 to 9). The robot is commanded using a sequence of moves, where each command is one of the four characters: U (move up), D (move down), L (move left), and R (move right). Note that moving U decreases the y-coordinate, D increases the y-coordinate, L decreases the x-coordinate, and R increases the x-coordinate.

The task is to determine whether the given sequence of commands brings the robot exactly to the target coordinate \( (target_x, target_y) \) without ever stepping outside the grid boundaries \( 0 \leq x, y \leq 9 \). If the robot goes out-of-bound at any step, the answer should be False immediately.

Note: The robot processes the commands sequentially starting from (0, 0). Even if the final location matches the target, if any command causes the robot to move out-of-bound, the overall answer is False.

inputFormat

The input is read from standard input (stdin) and has the following format:

target_x target_y
n
cmd1 cmd2 ... cmdn

Where target_x and target_y are integers representing the target coordinates, n is an integer representing the number of commands, and each cmd is a single character among U, D, L, and R.

outputFormat

The output is a single line printed to standard output (stdout). Output True (case sensitive) if the sequence of commands navigates the robot exactly to the target coordinate without going out-of-bound; otherwise, output False.

## sample
2 2
4
R R D D
True