A10606 | Interview with Oleg
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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!
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!
输入格式
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.
The second line contains the string $s$ of length $n$ , consisting of lowercase English letters.
输出格式
Print the interview text after the replacement of each of the fillers with "\*\*\*". It is allowed for the substring "\*\*\*" to have several consecutive occurences.
输入输出样例
输入 #1
7 aogogob
输出 #1
a***b
输入 #2
13 ogogmgogogogo
输出 #2
***gmg***
输入 #3
9 ogoogoogo
输出 #3
*********
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\*\*\*".
The second sample contains two fillers ogo and ogogogo. Thus, the interview is transformed to "\*\*\*gmg\*\*\*".
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted