QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 1024 MB

#23924. JOI 编辑器

통계

题目描述

以各种奇妙发明闻名的 JOI 公司最近开发了一款名为 JOI Editor 的文本编辑器。

这款文本编辑器可以用 j、o、i 这 $3$ 个按键来操作。按下 j、o、i 中的任意一个按键时,会输入该按键上所写的小写英文字母;但只要有 $2$ 个相同的小写英文字母相邻,这 $2$ 个字符就会立即被替换为对应的大写英文字母。也就是说,jj 会被替换为 JJ,oo 会被替换为 OO,ii 会被替换为 II。

例如,若按顺序按下 j、o、o、o、i 键,则在刚按完 j、o、o 键之后,第 $2$ 个字符与第 $3$ 个字符排列成 oo。由于有 $2$ 个相同的小写英文字母相邻,这 $2$ 个字符会立即被替换为 OO。最终写在 JOI Editor 中的字符串变为 jOOoi。注意不会变成 joOOi 或 jOOOi。

给定一个长度为 $N$ 的字符串 $S$。$S$ 的每个字符是 j、o、i 之一。

共按键 $N$ 次。$S$ 的第 $i$ 个字符($1 \le i \le N$)表示第 $i$ 次按下的按键。请输出最终写在 JOI Editor 中的字符串。

约束条件

  • $1 \le N \le 100$。
  • $S$ 是长度为 $N$ 的字符串。
  • $S$ 的每个字符是 j、o、i 之一。
  • $N$ 是整数。

输入格式

输入以如下格式给出:

N
S

输出格式

输出最终写在 JOI Editor 中的字符串。

样例

样例输入 1

6
jjoiii

样例输出 1

JJoIIi
  • 第 $1$ 次按下的按键是 j 键。写在 JOI Editor 中的字符串变为 j。
  • 第 $2$ 次按下的按键是 j 键。写在 JOI Editor 中的字符串变为 jj。
    • 由于相同的小写英文字母相邻,jj 被替换为 JJ,写在 JOI Editor 中的字符串变为 JJ。
  • 第 $3$ 次按下的按键是 o 键。写在 JOI Editor 中的字符串变为 JJo。
  • 第 $4$ 次按下的按键是 i 键。写在 JOI Editor 中的字符串变为 JJoi。
  • 第 $5$ 次按下的按键是 i 键。写在 JOI Editor 中的字符串变为 JJoii。
    • 由于相同的小写英文字母相邻,ii 被替换为 II,写在 JOI Editor 中的字符串变为 JJoII。
  • 第 $6$ 次按下的按键是 i 键。写在 JOI Editor 中的字符串变为 JJoIIi。

最终写在 JOI Editor 中的字符串是 JJoIIi,因此输出 JJoIIi。

样例输入 2

6
joijoi

样例输出 2

joijoi
  • 在此样例中不会发生替换。最终写在 JOI Editor 中的字符串是 joijoi,因此输出 joijoi。

样例输入 3

7
ooooooo

样例输出 3

OOOOOOo

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.