QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100

#23887. Bitaro and IOI

統計

Problem

You are given a string $S$ of length $N$. Each character of $S$ is one of B, I, T, A, R, or O.

Determine whether IOI exists as a (not necessarily contiguous) subsequence of the string $S$. In other words, determine whether there exists a triple of $3$ integers $(i, j, k)$ that satisfies the following conditions:

  • $1 \le i < j < k \le N$.
  • The $i$-th character of $S$ is I.
  • The $j$-th character of $S$ is O.
  • The $k$-th character of $S$ is I.

Constraints

  • $1 \le N \le 100$.
  • $S$ is a string of length $N$.
  • Each character of $S$ is one of B, I, T, A, R, or O.

Input

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

N
S

Output

Output Yes if IOI exists as a subsequence of the string $S$, and No otherwise.

Sample Input and Output

Sample Input 1

8
BITAROOI

Sample Output 1

Yes
  • The triples of $3$ integers $(2, 6, 8)$ and $(2, 7, 8)$ satisfy the conditions for $(i, j, k)$ in the problem statement. That is, IOI exists as a subsequence of the string $S$, so output Yes.

Sample Input 2

6
BBOOII

Sample Output 2

No
  • IOI does not exist as a subsequence of the string $S$, so output No.

Sample Input 3

5
IOIOI

Sample Output 3

Yes

Sample Input 4

9
RATRATRAT

Sample Output 4

No

Sample Input 5

1
A

Sample Output 5

No

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.