CF729A.Interview with Oleg
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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!
波利卡普采访了奥列格,并为了节省时间,将采访内容记录为一个不含标点符号和空格的字符串 s,该字符串由 n 个小写英文字母组成。
奥列格的讲话中包含一个填充词 ogo。所有可通过在 ogo 末尾重复添加 go 得到的单词也被视为填充词。例如,ogo、ogogo、ogogogo 是填充词,但 go、og、ogog、ogogog 和 oggo 不是填充词。
填充词应取最大可能长度。例如,对于字符串 ogogoo,我们不能将其中的 ogo 视为填充词而将剩余的 goo 视为正常语句;而应将 ogogo 视为一个填充词。
为了打印采访稿,波利卡普需将每个填充词替换为三个星号 ***。注意:无论填充词本身长度如何,均严格替换为恰好三个星号。
波利卡普瞬间就解决了这个问题。你也能做到吗?时间紧迫!
输入格式
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.
第一行包含一个正整数 n(1≤n≤100)—— 表示面试的长度。
第二行包含一个长度为 n 的字符串 s,由小写英文字母组成。
输出格式
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***".
第一个样例包含一个填充词“ogogo”,因此打印的面试结果为“a***b”。
第二个样例包含两个填充词“ogo”和“ogogogo”。因此,面试内容被转换为“***gmg***”。
输入解题思路,AI测评打分。不知道怎么写?