前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861C Did yo

Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861C Did yo

作者头像
Angel_Kitty
发布2018-04-09 15:57:06
6530
发布2018-04-09 15:57:06
举报

C. Did you mean...

time limit per test:1 second

memory limit per test:256 megabytes

input:standard input

output:standard output

Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.

Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block.

For example:

  • the following words have typos: "hellno", "hackcerrs" and "backtothefutttture";
  • the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo".

When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos.

Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem.

Input

The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.

Output

Print the given word without any changes if there are no typos.

If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.

Examples

Input

代码语言:javascript
复制
hellno

Output

代码语言:javascript
复制
hell no 

Input

代码语言:javascript
复制
abacaba

Output

代码语言:javascript
复制
abacaba 

Input

代码语言:javascript
复制
asdfasdf

Output

代码语言:javascript
复制
asd fasd f 

题目链接:http://codeforces.com/contest/861/problem/C

分析:直接看代码吧,代码中给出了详细注释!

下面给出AC代码:

代码语言:javascript
复制
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int N=3e3;
 4 int n;
 5 int a[N+10],is[400];
 6 char s[N+10];
 7 int main(void)
 8 {
 9     is['a']=is['e']=is['i']=is['o']=is['u']=1;
10     cin>>(s+1);
11     n=strlen(s+1);
12     int cnt=0;
13     for(int i=1;i<=n;i++)
14     {
15         if(!is[s[i]])
16         {
17             cnt++;
18             if(cnt>=3)
19             {
20                 bool ok=true;
21                 int j=max(1,i-2);
22                 for(int k=j;k<=i-1;k++)//前面的3个都和它一样吗
23                     if(s[k]!=s[i])
24                         ok=false;
25                 if(ok)//如果是的话
26                 {
27                     cout<<s[i];
28                     int k=i;
29                     while(k+1<=n&&s[k+1]==s[i])//往后一直找和它一样的
30                     {
31                         k++;
32                         cout<<s[k];
33                     }
34                     cnt=2;
35                     i=k;//cnt变成2了,指向下一个。
36                 }
37                 else//不是的话。只能分割了。
38                 {
39                     cout<<' '<<s[i];
40                     cnt=1;
41                 }
42             }
43             else
44                 cout<<s[i];//没3个
45         }
46         else//是元音直接输出
47         {
48             cout<<s[i];
49             cnt=0;
50         }
51     }
52     //连续出现
53 }
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-09-18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • C. Did you mean...
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档