Codeforces858c did you mean

阅读全文大概需要 3分钟
本文总阅读量
Posted by yjjr's blog on February 6, 2018

标签:贪心

Beroffice text editor has a wide range offeatures that help working with text. One of the features is an automaticsearch 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). Berofficethinks that a word is typed with a typo if there are three or more consonantsin a row in the word. The only exception is that if the block of consonants hasall letters the same, then this block (even if its length is greater thanthree) is not considered a typo. Formally, a word is typed with a typo if thereis a block of not less that three consonants in a row, and there are at leasttwo different letters in this block.

For example:

·                  the following wordshave typos: "hellno", "hackcerrs" and"backtothefutttture";

·                  the following wordsdon't have typos: "helllllooooo", "tobeornottobe" and "oooooo".

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

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

Input

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

Output

Print the given word without any changes if there are notypos.

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

Examples

input

hellno

output

hell no

input

abacaba

output

abacaba

input

asdfasdf

output

asd fasd f

 

题意:给你一个小写字母组成的字符串,如果其合法,那么直接输出,否则将其改为一个合法的串,从题面中再次体会到俄式英语的可怕

从前往后贪心就可以了

Code

#include<bits/stdc++.h>
#define LL long long 
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int maxn=3005;
char c[]="aeiou";
char s[maxn];

inline bool check(char ch)
{
	rep(i,0,4)if(ch==c[i])return 0;
	return 1;
}
int main()
{
	scanf("%s",s);
	int n=strlen(s),lst=-1;
	rep(i,0,n-1){
		putchar(s[i]);
		if(i!=n-1&&lst<=i-2&&check(s[i])&&check(s[i-1])&&check(s[i+1])&&(s[i]!=s[i-1]||s[i]!=s[i+1]||s[i-1]!=s[i+1]))
		{
			putchar(' ');
			lst=i;
		}
	}
	cout<<" ";
	return 0;
}



本文可以转载,但必须附上原文链接,否则你会终生找不到妹子!!!欢迎关注我的CSDN: ahyjjr