102960: [Atcoder]ABC296 A - Alternately

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:3 Solved:0

Description

Score : $100$ points

Problem Statement

There is a row of $N$ people. They are described by a string $S$ of length $N$. The $i$-th person from the front is male if the $i$-th character of $S$ 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

  • $1 \leq N \leq 100$
  • $N$ is an integer.
  • $S$ is a string of length $N$ consisting of M and F.

Input

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

$N$
$S$

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

Input

题意翻译

## 题目描述 有一排 $N$ 个人,由长度为 $S$ 的字符串 $N$ 表示。如果 $S$ 的第 $i$ 个字符是 $M$,则从前往后的第 $i$ 个人是男性,如果是 $F$,则为女性。 请确定男女是否交替。 据说,当且仅当没有两个男人或两个女人相邻的位置时,男人和女人是交替的。 ## 数据范围 - $1 \le N \le 100$ - $N$ 是整数 - $S$ 是一个长度为 $N$ 的,由 $M$ 与 $F$ 构成的字符串

Output

得分:100分 部分 问题描述 有一排有N个人。他们由一个长度为N的字符串S描述。从前面数的第i个人,如果S的第i个字符是M,则为男性;如果是F,则为女性。 确定男性和女性是否交替。 只有当没有两个男性或两个女性相邻的位置时,才说男性和女性是交替的。 部分 约束条件 * 1≤N≤100 * N是一个整数。 * S是一个由M和F组成的长度为N的字符串。 输入输出格式 输入 从标准输入给出以下格式的输入: N S 输出 如果男性和女性交替,则打印Yes;否则打印No。 样例输入1 6 MFMFMF 样例输出1 Yes 没有两个男性或两个女性相邻的位置,所以男性和女性是交替的。 样例输入2 9 FMFMMFMFM 样例输出2 No 样例输入3 1 F 样例输出3 Yes

HINT

n个人排队,判断是否男女交错排列?

加入题单

算法标签: