QOJ.ac

QOJ

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

#23924. JOI Editor

통계

Problem Statement

JOI Co., Ltd., known for its peculiar inventions, has recently developed a text editor called JOI Editor.

This text editor can be operated using $3$ keys: j, o, and i. When one of the keys j, o, or i is pressed, the lowercase English letter written on that key is typed; however, whenever $2$ identical lowercase English letters become adjacent, those $2$ characters are immediately replaced by the corresponding uppercase English letters. That is, jj is replaced by JJ, oo is replaced by OO, and ii is replaced by II.

For example, if the keys j, o, o, o, i are pressed in this order, immediately after pressing the keys up to j, o, o, the sequence of the $2$-nd and $3$-rd characters becomes oo. Since $2$ identical lowercase English letters are adjacent, these $2$ characters are immediately replaced by OO. Finally, the string written in JOI Editor becomes jOOoi. Note that it does not become joOOi or jOOOi.

A string $S$ of length $N$ is given. Each character of $S$ is one of j, o, i.

We press the keys $N$ times. The $i$-th character of $S$ ($1 \le i \le N$) represents the key pressed on the $i$-th press. Output the string finally written in JOI Editor.

Constraints

  • $1 \le N \le 100$.
  • $S$ is a string of length $N$.
  • Each character of $S$ is one of j, o, i.
  • $N$ is an integer.

Input

The input is given in the following format:

N
S

Output

Output the string finally written in JOI Editor.

Sample Input and Output

Sample Input 1

6
jjoiii

Sample Output 1

JJoIIi
  • The key pressed on the $1$-st press is the j key. The string written in JOI Editor becomes j.
  • The key pressed on the $2$-nd press is the j key. The string written in JOI Editor becomes jj.
    • Since identical lowercase English letters are adjacent, jj is replaced by JJ, and the string written in JOI Editor becomes JJ.
  • The key pressed on the $3$-rd press is the o key. The string written in JOI Editor becomes JJo.
  • The key pressed on the $4$-th press is the i key. The string written in JOI Editor becomes JJoi.
  • The key pressed on the $5$-th press is the i key. The string written in JOI Editor becomes JJoii.
    • Since identical lowercase English letters are adjacent, ii is replaced by II, and the string written in JOI Editor becomes JJoII.
  • The key pressed on the $6$-th press is the i key. The string written in JOI Editor becomes JJoIIi.

Finally, the string written in JOI Editor is JJoIIi, so output JJoIIi.

Sample Input 2

6
joijoi

Sample Output 2

joijoi
  • In this example, no replacement takes place. Finally, the string written in JOI Editor is joijoi, so output joijoi.

Sample Input 3

7
ooooooo

Sample Output 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.