QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 1024 MB Points totaux : 100

#23887. Bitaro and IOI

Statistiques

問題文

長さ $N$ の文字列 $S$ が与えられる.$S$ の各文字は B,I,T,A,R,O のいずれかである.

文字列 $S$ の (連続しているとは限らない) 部分列に IOI が存在するか判定せよ.つまり,次の条件を満たす $3$ つの整数の組 $(i,j,k)$ が存在するか判定せよ.

  • $1 ≦ i < j < k ≦ N$.
  • $S$ の $i$ 文字目は I である.
  • $S$ の $j$ 文字目は O である.
  • $S$ の $k$ 文字目は I である.

制約

  • $1 ≦ N ≦ 100$.
  • $S$ は長さ $N$ の文字列である.
  • $S$ の各文字は B,I,T,A,R,O のいずれかである.

入力

入力は以下の形式で標準入力から与えられる.
$N$
$S$

出力

文字列 $S$ の部分列に IOI が存在する場合は Yes を,そうでない場合は No を出力せよ.

入出力例

入力例 1
8
BITAROOI

出力例 1
Yes

  • $3$ つの整数の組 $(2,6,8)$ や $(2,7,8)$ は問題文中の $(i,j,k)$ の条件を満たす.つまり,文字列 $S$ の部分列に IOI が存在するので,Yes を出力する.

入力例 2
6
BBOOII

出力例 2
No

  • 文字列 $S$ の部分列に IOI は存在しないので,No を出力する.

入力例 3
5
IOIOI

出力例 3
Yes


入力例 4
9
RATRATRAT

出力例 4
No


入力例 5
1
A

出力例 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.