QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#23887. 비타로와 IOI

Statistics

문제

길이가 $N$인 문자열 $S$가 주어진다. $S$의 각 문자는 B, I, T, A, R, O 중 하나이다.

문자열 $S$의 (연속해 있다고는 할 수 없는) 부분 수열에 IOI가 존재하는지 판정하시오. 즉, 다음 조건을 만족하는 $3$개의 정수의 쌍 $(i, j, k)$가 존재하는지 판정하시오.

  • $1 \le i < j < k \le N$.
  • $S$의 $i$번째 문자는 I이다.
  • $S$의 $j$번째 문자는 O이다.
  • $S$의 $k$번째 문자는 I이다.

제약 조건

  • $1 \le N \le 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.