Official

A - mnclr Editorial by en_translator


If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (https://atcoder.jp/contests/abs).


Consider constructing the desired string and printing it.

Let \(T\) be the answer string. \(T\) has a length \(2\times(\text{length of }S)-1\). The \(1\)-st, \(3\)-rd, \(5\)-th, \(\dots\) characters of \(T\) are the \(1\)-st, \(2\)-nd, \(3\)-rd, \(\dots\) characters of \(S\), and the \(2\)-nd, \(4\)-th, \(6\)-th, \(\dots\) characters of \(T\) are all o. \(T\) can be constructed with a for statement.

Beware that most languages start indices of an array from \(0\).

Sample code (C++)

#include<bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  string t(2*n-1,' ');
  for(int i=0;i<n;i++)t[2*i]=s[i];
  for(int i=1;i<n;i++)t[2*i-1]='o';
  cout << t << endl;
}

In Python, one can use the join method to implement concisely.

Sample code (Python)

S=input()
print("o".join(S))