atcoder#ABC291C. [ABC291C] LRUD Instructions 2
[ABC291C] LRUD Instructions 2
Score : points
Problem Statement
Takahashi is on a two-dimensional plane. Starting from the origin, he made moves.
The moves are represented by a string of length as described below:
-
Takahashi's coordinates after the -th move are:
- if the -th character of is
R
; - if the -th character of is
L
; - if the -th character of is
U
; and - if the -th character of is
D
,
where is his coordinates before the move.
- if the -th character of is
-
if the -th character of is
R
; -
if the -th character of is
L
; -
if the -th character of is
U
; and -
if the -th character of is
D
,
Determine if Takahashi visited the same coordinates multiple times in the course of the moves (including the starting and ending points).
Constraints
- is an integer.
- is a string of length consisting of
R
,L
,U
, andD
.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if Takahashi visited the same coordinates multiple times in the course of the moves; print No
otherwise.
5
RLURU
Yes
Takahashi's coordinates change as follows: .
20
URDDLLUUURRRDDDDLLLL
No