#K2631. Robot Movement Command Processing

    ID: 24780 Type: Default 1000ms 256MiB

Robot Movement Command Processing

Robot Movement Command Processing

A virtual robot is placed on an infinite grid with its starting position at the origin \((0,0)\). The robot receives a sequence of movement commands to navigate the grid. Each command consists of a direction letter immediately followed by a digit (1-9) that denotes the number of units to move in that direction.

The directions are:

  • U: Move up (increase y-coordinate)
  • D: Move down (decrease y-coordinate)
  • L: Move left (decrease x-coordinate)
  • R: Move right (increase x-coordinate)

Your task is to process the command string and output the final coordinates of the robot in the format (x, y).

For example, if the input command is \(R3U2L1D2\), the final position would be \((2, 0)\).

inputFormat

The input consists of a single line containing a string of commands. Each command is represented by a character for the direction followed by a single digit (1-9) indicating the number of units to move.

You should read the entire input from standard input (stdin).

outputFormat

Output a single line: the final coordinates of the robot in the format (x, y) printed to standard output (stdout).

## sample
R3U2L1D2
(2, 0)