#C10604. Robot Movement: Final Position and Return Check

    ID: 39828 Type: Default 1000ms 256MiB

Robot Movement: Final Position and Return Check

Robot Movement: Final Position and Return Check

You are given a string representing the moves of a robot on a 2D plane. The robot starts at the origin \((0, 0)\). Each character in the string corresponds to a move:

  • U: Move up (increment \(y\) by 1).
  • D: Move down (decrement \(y\) by 1).
  • L: Move left (decrement \(x\) by 1).
  • R: Move right (increment \(x\) by 1).

The final coordinates \((x, y)\) can be computed using the formulas:

\( x = \#(R) - \#(L) \)

\( y = \#(U) - \#(D) \)

After performing all moves, print the final coordinates followed by "YES" if the robot returns to the origin (i.e. \(x = 0\) and \(y = 0\)), otherwise print "NO".

inputFormat

The input consists of a single line string that represents the moves of the robot. The string contains only the characters U, D, L, and R. The string may be empty.

outputFormat

Print three space-separated items: the final x coordinate, the final y coordinate, and either YES if the robot returns to the origin or NO otherwise.

## sample
UUDDLRLR
0 0 YES