coderforces-738A

A. Interview with Oleg
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard 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 ogoogogoogogogo are fillers, but the words googogogogogog 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
Copy
7
aogogob
output
Copy
a***b
input
Copy
13
ogogmgogogogo
output
Copy
***gmg***
input
Copy
9
ogoogoogo
output
Copy
*********
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***".

题目大意:对于给定字符串,如果遇到ogo则输出三个星号,如果ogo后面跟着几个go那么忽略这些go,遇到其他组合的字符原样输出即可。

代码:

#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        char s[100];
        int i,j;
        scanf("%s",s);
        for(i=0;i<n;)
        {
            if(s[i]=='o'&&s[i+1]=='g'&&s[i+2]=='o')
            {
                printf("***");
                i+=3;
                while(s[i]=='g'&&s[i+1]=='o')
                    i+=2;
            }
            else
            {
                printf("%c",s[i]);
                i++;
            }
        }
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
public void queryShopList() throws Exception { String session3rd = getSession3rd(); Map<String, String> head = new HashMap<>(); head.put("session3rd", session3rd); head.put("v", "100"); HttpHeaders httpHeaders = TestHeadUtil.getHttpHeaders(); httpHeaders.set("openId", "ossjE5VyWgsU-QcNKO_3OfpBNG3c"); httpHeaders.set("appType", "nft"); httpHeaders.set("v", "100"); httpHeaders.set("session3rd", session3rd); Map<String, String> bean = new HashMap<>(); bean.put("session3rd", session3rd); bean.put("couponId", "207504"); bean.put("lat", "23.12463"); bean.put("lng", "113.36199"); bean.put("limit", "10"); bean.put("page", "1"); // bean.put("data", "45FD95D0B7A233898C8ECA775042ECCC0860525875BB738A030389B0C3E9B7CBEB3A4B6636CC9732057434FFC32D11186E2C4176B84B06904D122E0400692CFBB24115ACB1F6DB7755CF5AAC1F7F1B95C9D8A398867DFFC45B6DC6274E154D8E7FDD34A9E11558D9AE161ECC8DF808377429A850FB48344FFC7000E3ED1257F2D3B565E5ED39AA67CFDE867C02DE9614341A3E55F52391D5B50834BD00B05C16"); // String content = RequestUtil.getEncodeParam(session, bean); String content = JSONObject.toJSONString(bean); ResultActions resultActions = mvc.perform(MockMvcRequestBuilders.post("/api/yiqilaiCoupon/coupon/queryShopList") .content(content).contentType(MediaType.APPLICATION_JSON) //.contentType(MediaType.TEXT_PLAIN) .headers(httpHeaders)) .andExpect(status().isOk()); resultActions.andReturn().getResponse().setCharacterEncoding("UTF-8"); String json = resultActions.andDo(print()).andReturn().getResponse().getContentAsString(); assert JSONObject.parseObject(json).getIntValue("result") == 0; }
最新发布
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值