QOJ.ac

QOJ

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

#23903. 下一個字符

Statistics

給定一個長度為 $N$ 嘅字符串 $S$。$S$ 嘅每個字符都係 J、O、I 入面嘅其中一種。

海狸比太郎進行咗 $N - 1$ 次操作。第 $i$ 次($1 \le i \le N - 1$)操作按以下方式進行:

  • 檢查 $S$ 嘅第 $(i + 1)$ 個字符。進一步噉講,如果 $S$ 嘅第 $(i + 1)$ 個字符係 J,就喺黑板上面寫低 $S$ 嘅第 $i$ 個字符。

請將 $N - 1$ 次操作入面比太郎喺黑板上面寫低嘅所有字符,按比太郎寫低嘅順序以換行分隔輸出。

輸入格式

輸入由標準輸入按以下格式給出:

N
S

輸出格式

將 $N - 1$ 次操作入面比太郎喺黑板上面寫低嘅所有字符,按比太郎寫低嘅順序以換行分隔輸出。

數據範圍

  • $2 \le N \le 100$。
  • $S$ 係長度為 $N$ 嘅字符串。
  • $S$ 嘅每個字符都係 J、O、I 入面嘅其中一種。
  • $N$ 係整數。
  • 黑板上面寫低嘅字符至少有 $1$ 個。

範例

範例輸入 1

6
IOJOIJ

範例輸出 1

O
I

比太郎按以下方式進行咗 $5$ 次操作:

  • 喺第 $1$ 次操作入面,檢查咗 $S$ 嘅第 $2$ 個字符。
  • 喺第 $2$ 次操作入面,檢查咗 $S$ 嘅第 $3$ 個字符。進一步噉講,由於 $S$ 嘅第 $3$ 個字符係 J,因此喺黑板上面寫低咗 $S$ 嘅第 $2$ 個字符 O。
  • 喺第 $3$ 次操作入面,檢查咗 $S$ 嘅第 $4$ 個字符。
  • 喺第 $4$ 次操作入面,檢查咗 $S$ 嘅第 $5$ 個字符。
  • 喺第 $5$ 次操作入面,檢查咗 $S$ 嘅第 $6$ 個字符。進一步噉講,由於 $S$ 嘅第 $6$ 個字符係 J,因此喺黑板上面寫低咗 $S$ 嘅第 $5$ 個字符 I。

因此,將比太郎喺黑板上面寫低嘅 O 同 I 按呢個順序以換行分隔輸出。

範例輸入 2

4
JJOI

範例輸出 2

J

比太郎喺第 $1$ 次操作入面將 $S$ 嘅第 $1$ 個字符 J 寫咗喺黑板上面。喺第 $2$ 次同第 $3$ 次操作入面,冇喺黑板上面寫任何嘢。

因此,輸出比太郎喺黑板上面寫低嘅 J。

範例輸入 3

7
IOJOJOJ

範例輸出 3

O
O
O

範例輸入 4

5
JJJJJ

範例輸出 4

J
J
J
J

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.