#abc296a. A - Alternately

A - Alternately

Score : 100100 points

问题陈述

有一排共 NN 个人。他们由长度为 NN 的字符串 SS 描述。若第 ii 个字符为 M,则表示从前往后数的第 ii 个人是男性;若为 F,则表示该人是女性。

确定这一排男性和女性是否交替站立。

我们称男性和女性是交替站立的,当且仅当不存在任何位置使得相邻的两个人都是男性或都是女性。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There is a row of NN people. They are described by a string SS of length NN. The ii-th person from the front is male if the ii-th character of SS is M, and female if it is F.

Determine whether the men and women are alternating.

It is said that the men and women are alternating if and only if there is no position where two men or two women are adjacent.

Constraints

  • 1N1001 \leq N \leq 100
  • NN is an integer.
  • SS is a string of length NN consisting of M and F.

Input

The input is given from Standard Input in the following format:

NN

SS

Output

Print Yes if the men and women are alternating, and No otherwise.

Sample Input 1

6
MFMFMF

Sample Output 1

Yes

There is no position where two men or two women are adjacent, so the men and women are alternating.

Sample Input 2

9
FMFMMFMFM

Sample Output 2

No

Sample Input 3

1
F

Sample Output 3

Yes

update @ 2024/3/10 12:17:33