Monday 30 January 2017

Technocup 2017 - Elimination Round 2/A. Interview with Oleg

Problem: http://codeforces.com/contest/729/problem/A
Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i;
    string s,k;
    while(cin>>n>>s)
    {
        k="";
        for(i=0;i<n;i++)
        {
            if(s[i]=='o'&&s[i+1]=='g'&&s[i+2]=='o')
            {
                k+="***";
                i++;
                while(s[i]=='g'&&s[i+1]=='o')
                {
                    i+=2;
                }
                i--;
                //cout<<i<<endl;
            }
            else
                k+=s[i];
               // cout<<k<<endl;
            //i++;
        }
        cout<<k<<endl;

    }
    return 0;
}

No comments:

Post a Comment