#C8026. Robot Returns to Origin
Robot Returns to Origin
Robot Returns to Origin
Given a string representing a sequence of moves, determine whether a robot that starts at the origin \((0,0)\) returns to the origin after executing all the moves. The robot can move in four directions: 'L' (left), 'R' (right), 'U' (up), and 'D' (down). Each move changes the robot's coordinates by exactly one unit in the respective direction. Your task is to check if, after executing all moves, the robot's final position is exactly at \((0,0)\).
inputFormat
The input consists of a single line containing a non-empty string \(S\) of characters. Each character in \(S\) is one of 'L', 'R', 'U', or 'D', representing a move of the robot.
outputFormat
Output a single line containing YES
if the robot returns to the origin \((0,0)\); otherwise, output NO
.
LR
YES