#C6157. Robot Return to Origin

    ID: 49886 Type: Default 1000ms 256MiB

Robot Return to Origin

Robot Return to Origin

A robot moves on a 2D grid. The robot is given a sequence of moves, where each move is represented by one of the characters: U (up), D (down), L (left), and R (right).

Your task is to determine whether the robot returns to the origin (0, 0) after executing all the moves. Mathematically, if we let the net displacement in the x direction be \(\Delta x\) and in the y direction be \(\Delta y\), then the robot returns to the origin if and only if \(\Delta x = 0 \text{ and } \Delta y = 0\).

For example, if the input command is UD, then the robot moves up and then down, thereby returning to the origin, and the expected output is Yes.

inputFormat

A single line input containing a non-empty string consisting only of the characters U, D, L, and R. This string represents the sequence of moves.

outputFormat

Output a single line: Yes if the robot returns to the origin (0, 0) after executing all moves, otherwise output No.## sample

UD
Yes