题目描述
Problem Description
In the capital of okayama kingdom, ookayama, a string with one or more o characters prepended to ookayama is called a good string.
Your task is to write a program that processes the string \( S \) according to the following rules:
- Step 1. If \( S \) contains a substring that is a good string, proceed to Step 2. Otherwise, end the process.
- Step 2. Among the substrings of \( S \) that are good strings, choose the longest one and denote it as \( T \). If there are multiple longest ones, choose the one that appears furthest to the left. Proceed to Step 3.
- Step 3. If \( T \) contains the substring
oo, replace the leftmost occurrence ofoowithOand proceed to Step 4. Ifoodoes not exist, go back to Step 1. - Step 4. If \( T \) contains the substring
OO, replace the leftmost occurrence ofOOwitho. Regardless of whetherOOexists or not, go back to Step 3.
Determine the final \( S \) after the process ends. The purpose of this processing result is classified, so you do not need to know it.
A string \( T \) is called a substring of \( S \) if it is extracted from \( S \) starting from the \( i \)-th (\( 1 \leq i \leq |S| \)) character to the \( j \)-th (\( i \leq j \leq |S| \)) character. Here, \( |S| \) denotes the length of the string \( S \).
Input Format
The input is given from the standard input in the following format:
\( S \)
The first line contains the string \( S \) (\( 1 \leq |S| \leq 100 \)), which is to be processed. \( S \) is guaranteed to consist only of lowercase English letters.
Output Format
Output the final \( S \) after the process ends on one line. Do not forget to add a newline.
Sample Input and Output
Sample Input #1
ooookayama
Sample Output #1
okayama
Sample Input #2
ooookayamaoooookayama
Sample Output #2
okayamaOkayama
Sample Input #3
okayama
Sample Output #3
okayama
Sample Input #4
ookayama
Sample Output #4
ookayama
Sample Input #5
ooookayamakenooooookayamashiookayama
Sample Output #5
okayamakenOokayamashiookayama
Notes/Hints
Sample Explanation 1
For the string ooookayama, the process proceeds as follows:
1. In Step 1, a good substring exists in \( S \).
2. In Step 2, the longest good substring starting from the 1st o is ooookayama, which is denoted as \( T \).
3. In Step 3, the leftmost oo in \( T \) is replaced with O, making \( T \) Oookayama.
4. In Step 4, there is no OO in \( T \).
5. In Step 3, the leftmost oo in \( T \) is replaced with O, making \( T \) OOkayama.
6. In Step 4, the leftmost OO in \( T \) is replaced with o, making \( T \) okayama.
7. In Step 3, there is no oo in \( T \).
8. In Step 1, \( S \) is now okayama, which contains no good substrings. The process ends.
Sample Explanation 2
Multiple good substrings may exist in \( S \). It is important to process the longest one that appears furthest to the left. Note that although the input does not contain uppercase letters, they may appear in the answer or during the process.
Sample Explanation 3
No good substrings exist in the string okayama.
Sample Explanation 4
No good substrings exist in the string ookayama. A good string is defined as a string with one or more o characters prepended to ookayama, so ookayama does not meet the criteria.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分