atcoder#AGC003A. [AGC003A] Wanna go back home
[AGC003A] Wanna go back home
Score : points
Problem Statement
Snuke lives on an infinite two-dimensional plane. He is going on an -day trip. At the beginning of Day , he is at home. His plan is described in a string of length . On Day , he will travel a positive distance in the following direction:
- North if the -th letter of is
N
- West if the -th letter of is
W
- South if the -th letter of is
S
- East if the -th letter of is
E
He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day .
Constraints
- consists of the letters
N
,W
,S
,E
.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if it is possible to set each day's travel distance so that he will be back at home at the end of Day . Otherwise, print No
.
SENW
Yes
If Snuke travels a distance of on each day, he will be back at home at the end of day .
NSNNSNSN
Yes
NNEW
No
W
No