/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
. および # からなる文字列 S が与えられます。
以下の条件を全て満たす文字列 T のうち、 o の文字数が最大となるものを一つ求めてください。
- T の長さは S の長さと等しい。
- T は
.、#、oからなる。 - S_i=
#であるとき、またそのときに限り T_i=#である。 - T_i=T_j=
o(i < j) ならば、 T_{i+1},\ldots,T_{j-1} の中に#が 1 つ以上存在する。
制約
- S は
.および#からなる長さ 1 以上 100 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
条件を全て満たす文字列 T のうち、 o の文字数が最大となるものを一つ出力せよ。
そのような文字列が複数ある場合、どれを出力しても正答となる。
入力例 1
#..#.
出力例 1
#o.#o
T= #o.#o とすると全ての条件を満たすことが確認できます。
全ての条件を満たす T であって、 o の文字数が 2 より多い文字列は存在しないので #o.#o を出力すると正答となります。
この他にも #.o#o を出力しても正答となります。
入力例 2
#
出力例 2
#
入力例 3
.....
出力例 3
..o..
この他にも o....、.o...、...o.、....o を出力しても正答となります。
入力例 4
...#..#.##.#.
出力例 4
o..#.o#o##o#o
Score : 250 points
Problem Statement
You are given a string S consisting of . and #.
Among all strings T that satisfy all of the following conditions, find one with the maximum number of os.
- The length of T is equal to the length of S.
- T consists of
.,#, oro. - T_i=
#if and only if S_i=#. - If T_i=T_j=
o(i < j), then there exists at least one#among T_{i+1},\ldots,T_{j-1}.
Constraints
- S is a string consisting of
.and#with length between 1 and 100, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Output one string with the maximum number of os among all strings T that satisfy all conditions.
If there are multiple such strings, printing any of them will be considered correct.
Sample Input 1
#..#.
Sample Output 1
#o.#o
Setting T= #o.#o satisfies all conditions.
There is no string T that satisfies all conditions and has more than two os, so outputting #o.#o is correct.
Outputting #.o#o is also correct.
Sample Input 2
#
Sample Output 2
#
Sample Input 3
.....
Sample Output 3
..o..
Outputting o...., .o..., ...o., or ....o is also correct.
Sample Input 4
...#..#.##.#.
Sample Output 4
o..#.o#o##o#o