AtCoder Grand Contest 003
翻译中…
Problem Statement
翻译中…
Snuke lives on an infinite two-dimensional plane. He is going on an $N$-day trip. At the beginning of Day $1$, he is at home. His plan is described in a string $S$ of length $N$. On Day $i(1 ≦ i ≦ N)$, he will travel a positive distance in the following direction:
翻译中…
- North if the
$i$-th letter of$S$isN - West if the
$i$-th letter of$S$isW - South if the
$i$-th letter of$S$isS - East if the
$i$-th letter of$S$isE
翻译中…
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 $N$.
翻译中…
Constraints
翻译中…
$1 ≦ | S | ≦ 1000$$S$consists of the lettersN,W,S,E.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
S
翻译中…
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 $N$. Otherwise, print No.
翻译中…
样例
Input #1
SENW
Output #1
Yes
If Snuke travels a distance of $1$ on each day, he will be back at home at the end of day $4$.
Input #2
NSNNSNSN
Output #2
Yes
Input #3
NNEW
Output #3
No
Input #4
W
Output #4
No
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。