QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 1024 MB

#23971. 葵與 IOI

الإحصائيات

給定一個長度為 $N$ 的字串 $S$。$S$ 的每個字元皆為 A、O、I 中的一個。

取出 $S$ 中包含的連續 $3$ 個字元時,請輸出按順序為 A、O、I 或 I、O、I 的子字串個數。

限制條件

  • $1 \le N \le 100$。
  • $S$ 是長度為 $N$ 的字串。
  • $S$ 的每個字元皆為 A、O、I 中的一個。
  • $N$ 是整數。

輸入格式

輸入以下列格式給出:

N
S

輸出格式

輸出 $S$ 中包含的 AOI 的個數與 IOI 的個數之和。

除答案外請勿輸出任何內容。(亦請勿輸出提示輸入的文字等。)

範例

範例輸入 1

5
IAOIO

範例輸出 1

1

範例說明 1

  • $S$ 的第 $2$、$3$、$4$ 個字元分別為 A、O、I。
  • $S$ 中沒有按此順序連續出現 I、O、I 這 $3$ 個字元。

$S$ 中包含的 AOI、IOI 的個數之和為 $1$。因此輸出 $1$。

範例輸入 2

8
AOIOIOIA

範例輸出 2

3

範例說明 2

  • $S$ 的第 $1$、$2$、$3$ 個字元分別為 A、O、I。
  • $S$ 的第 $3$、$4$、$5$ 個字元分別為 I、O、I。
  • $S$ 的第 $5$、$6$、$7$ 個字元分別為 I、O、I。

$S$ 中包含的 AOI、IOI 的個數之和為 $3$。因此輸出 $3$。

範例輸入 3

6
IIOOII

範例輸出 3

0

範例說明 3

AOI、IOI 皆不包含在 $S$ 中。因此輸出 $0$。

範例輸入 4

15
IAOIAOAOIOIAIOI

範例輸出 4

4

範例說明 4

$S$ 中包含的 AOI、IOI 的個數之和為 $4$。因此輸出 $4$。

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.