

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
高橋君は 個の料理を食べようとしています。
番目に食べようとしている料理は、 sweet
のとき甘い料理であり、 salty
のとき塩辛い料理です。
高橋君は甘い料理を つ連続で食べると気持ち悪くなってしまい、その後料理が食べられなくなってしまいます。
高橋君がすべての料理を食べることができるか判定してください。
制約
- は 以上 以下の整数
- は
sweet
またはsalty
入力
入力は以下の形式で標準入力から与えられる。
出力
高橋君がすべての料理を食べることができるならば Yes
を、できないならば No
を出力せよ。
入力例 1Copy
5 salty sweet salty salty sweet
出力例 1Copy
Yes
高橋君は甘い料理を つ連続で食べることがないので、気持ち悪くなることなくすべての料理を食べることができます。
入力例 2Copy
4 sweet salty sweet sweet
出力例 2Copy
Yes
高橋君は気持ち悪くなってしまいますが、すべての料理を食べることができます。
入力例 3Copy
6 salty sweet sweet salty sweet sweet
出力例 3Copy
No
高橋君は 番目の料理を食べると気持ち悪くなってしまい、 番目以降の料理が食べられなくなります。
Score : points
Problem Statement
Takahashi is planning to eat dishes.
The -th dish he plans to eat is sweet if sweet
, and salty if salty
.
If he eats two sweet dishes consecutively, he will feel sick and be unable to eat any more dishes.
Determine whether he can eat all the dishes.
Constraints
- is an integer between and , inclusive.
- Each is
sweet
orsalty
.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if Takahashi can eat all the dishes, and No
otherwise.
Sample Input 1Copy
5 salty sweet salty salty sweet
Sample Output 1Copy
Yes
He will not eat two sweet dishes consecutively, so he can eat all the dishes without feeling sick.
Sample Input 2Copy
4 sweet salty sweet sweet
Sample Output 2Copy
Yes
He will feel sick but can still eat all the dishes.
Sample Input 3Copy
6 salty sweet sweet salty sweet sweet
Sample Output 3Copy
No
He feels sick when eating the 3rd dish and cannot eat the 4th and subsequent dishes.