Alternately

AtCoder
IDabc296_a
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
Input #1
6
MFMFMF
Output #1
Yes

There is no position where two men or two women are adjacent, so the men and women are alternating.
Input #2
9
FMFMMFMFM
Output #2
No
Input #3
1
F
Output #3
Yes
API Response (JSON)
{
  "problem": {
    "name": "Alternately",
    "description": {
      "content": "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 whe",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc296_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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`.\nDetermine whe...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments