time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.

There is a filler word ogo in Oleg’s speech. All words that can be obtained from ogo by adding go several times to the end of it are also considered to be fillers. For example, the words ogo, ogogo, ogogogo are fillers, but the words go, og, ogog, ogogog and oggo are not fillers.

The fillers have maximal size, for example, for ogogoo speech we can’t consider ogo a filler and goo as a normal phrase. We should consider ogogo as a filler here.

To print the interview, Polycarp has to replace each of the fillers with three asterisks. Note that a filler word is replaced with exactly three asterisks regardless of its length.

Polycarp has dealt with this problem in no time. Can you do the same? The clock is ticking!

Input

The first line contains a positive integer n (1 ≤ n ≤ 100) — the length of the interview.

The second line contains the string s of length n, consisting of lowercase English letters.

Output

Print the interview text after the replacement of each of the fillers with ““. It is allowed for the substring “” to have several consecutive occurences.

Examples

input

7

aogogob

output

a***b

input

13

ogogmgogogogo

output

gmg

input

9

ogoogoogo

output


Note

The first sample contains one filler word ogogo, so the interview for printing is “a***b”.

The second sample contains two fillers ogo and ogogogo. Thus, the interview is transformed to “gmg“.

【题目链接】:http://codeforces.com/contest/738/problem/A

【题解】



找到第一个ogo的位置,然后往后找”go”;把ogo替换成三个*;后面的go替换成一个标识符&,最后不输出就好;

(或者你找到一个就直接输出三个*,其他的按照原序列输出也可以)

简单的字符串处理;



【完整代码】

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. string s;
  4. int n;
  5. int main()
  6. {
  7. //freopen("F:\\rush.txt","r",stdin);
  8. cin >> n;
  9. cin >> s;
  10. int len = s.size();
  11. for (int i = 0;i <= len-1;i++)
  12. if (i+2<=len-1 && s[i]=='o' && s[i+1]=='g' && s[i+2]=='o')
  13. {
  14. int j = i+3;
  15. while (j+1<=len-1 && s[j]=='g' && s[j+1]=='o')
  16. {
  17. j+=2;
  18. }
  19. for (int k = i;k <= i+2;k++)
  20. s[k] = '*';
  21. for (int k = i+3;k <= j-1;k++)
  22. s[k] = '$';
  23. i = j-1;
  24. }
  25. for (int i = 0;i <= len-1;i++)
  26. if (s[i]!='$')
  27. putchar(s[i]);
  28. return 0;
  29. }

【57.97%】【codeforces Round #380A】Interview with Oleg的更多相关文章

  1. 【42.86%】【Codeforces Round #380D】Sea Battle

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. 【26.83%】【Codeforces Round #380C】Road to Cinema

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. 【21.21%】【codeforces round 382D】Taxes

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【50.88%】【Codeforces round 382B】Urbanization

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【Codeforces Round 1137】Codeforces #545 (Div. 1)

    Codeforces Round 1137 这场比赛做了\(A\).\(B\),排名\(376\). 主要是\(A\)题做的时间又长又交了两次\(wa4\)的. 这两次错误的提交是因为我第一开始想的求 ...

  6. 【Codeforces Round 1132】Educational Round 61

    Codeforces Round 1132 这场比赛做了\(A\).\(B\).\(C\).\(F\)四题,排名\(89\). \(A\)题\(wa\)了一次,少考虑了一种情况 \(D\)题最后做出来 ...

  7. 【Codeforces Round 1120】Technocup 2019 Final Round (Div. 1)

    Codeforces Round 1120 这场比赛做了\(A\).\(C\)两题,排名\(73\). \(A\)题其实过的有点莫名其妙...就是我感觉好像能找到一个反例(现在发现我的算法是对的... ...

  8. 【Codeforces Round 1129】Alex Lopashev Thanks-Round (Div. 1)

    Codeforces Round 1129 这场模拟比赛做了\(A1\).\(A2\).\(B\).\(C\),\(Div.1\)排名40. \(A\)题是道贪心,可以考虑每一个站点是分开来的,把目的 ...

  9. 【Codeforces Round 1117】Educational Round 60

    Codeforces Round 1117 这场比赛做了\(A\).\(B\).\(C\).\(D\).\(E\),\(div.2\)排名\(31\),加上\(div.1\)排名\(64\). 主要是 ...

随机推荐

  1. adb logcat 使用

    之前打印log的时候,使用的是别人配置好的快捷键,结果现在快捷键没有配置,具体的log命令就不会了.今天上网查了一下,记录下来 打印的log是 android.util.Log.e("zha ...

  2. js插件---datatables如何使用

    js插件---datatables如何使用 一.总结 一句话总结:a.引入css和js(不要忘记css):b.js代码启动插件(里面可以用参数控制各种功能) 1.dataTables如何显示控制行(比 ...

  3. 关于exports 和 module.exports

    本文来源为node.js社区附上链接 http://cnodejs.org/topic/5231a630101e574521e45ef8 require 用来加载代码,而 exports 和 modu ...

  4. JS中的预解析

    js预解析对于很多学习web前端开发的新手们很困扰,总是很难搞懂到底是个什么东西,今天零度就为大家简单的分析一下,争取让大家都明白! 首先,看一下下面的代码: alert(a); var a = 1; ...

  5. 9.多彩的幕布layer

    CCLayerCorlor bool CCLayerColor::initWithColor(const ccColor4B & color); bool CCLayerColor::init ...

  6. JQ 实施编辑 (clone()复制行||双击编辑)

    //代码 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...

  7. OpenCV —— 矩阵操作

    多通道的矩阵 —— 通道是连续的!! 要将指向该数据类型的指针移动到下一通道,我们只需要将其增加1.如果想访问下一个“像素”或者元素集,则需要一定的偏移量 矩阵的step元素是矩阵中行的长度,单位为字 ...

  8. Python笔记---错误笔记

    Python---错误笔记 1. Python编码问题: 我们在编写 Python 脚本时,往往会写上中文凝视. 可是有时候,当我们执行程序时.却发现例如以下错误:SyntaxError: Non-A ...

  9. 重建一些被PHP7废弃的函数,

    <?php if(!function_exists('ereg')) { function ereg($pattern, $subject, &$matches = []) { retu ...

  10. Android系统如何管理自己内存的?

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 机缘巧合写下这篇博客,作为个人工作经验的总结,不足之处,随后补上. 安卓是基于Linux2.6内核的 ...