#C4967. Return to Origin
Return to Origin
Return to Origin
You are given a string s
consisting solely of the characters 'U', 'D', 'L', and 'R'. Each character represents a move in a two-dimensional grid:
- 'U' denotes a move upward, increasing the y-coordinate by 1.
- 'D' denotes a move downward, decreasing the y-coordinate by 1.
- 'L' denotes a move to the left, decreasing the x-coordinate by 1.
- 'R' denotes a move to the right, increasing the x-coordinate by 1.
You start at the origin \( (0,0) \). Determine whether the sequence of movements returns you to the origin. If yes, print "Yes", otherwise print "No".
Note: The moves are executed in the order they appear in the string.
inputFormat
The input consists of a single line containing a non-empty string s
with characters from the set {'U', 'D', 'L', 'R'}.
The input is read from standard input (stdin).
outputFormat
Output a single line with the string "Yes" if the given moves return to the origin, and "No" otherwise. The output is written to standard output (stdout).
## sampleU
No