CodeForces

来源:互联网 发布:ubuntu qq2012国际版 编辑:程序博客网 时间:2024/06/17 22:16

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 between1 and3000 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.

Example
Input
hellno
Output
hell no 
Input
abacaba
Output
abacaba 
Input
asdfasdf
Output
asd fasd f 

题意:(全靠猜);

思路:写的繁琐了,其实就是按照题意去模拟,但注意的点比较多,耐着点wa过去就行;

#include <cstdio>#include <cstring>#define MAXN 3010typedef long long LL;char ch[MAXN];int a[MAXN];bool get_(char s) {        if(s == 'a' || s == 'o' || s == 'e' || s == 'i' || s == 'u')                return true;        return false;}int main() {        scanf("%s", ch);        int len = strlen(ch);        int cnt = 0, res;        for(int i = 0; i < len; i++) {                if(get_(ch[i])) {                        cnt = 0;                }                else {                        int id = i;                        while(ch[id] == ch[id + 1]) {                                id++;                        }                        res = id - i + 1;                        if(cnt == 0) {                                if(res <= 2) {                                        cnt = res;                                }                                else {                                        if(!get_(ch[id + 1]))                                                a[id + 1] = 1;                                }                                i = id;                        }                        else if(cnt) {                                if(res + cnt < 3) {                                        cnt += res;                                        i = id;                                }                                else {                                        if(cnt == 1) {                                                a[i + 1] = 1;                                                if(res - 1 >= 3) {                                                        cnt = 0;                                                        i = id;                                                        if(!get_(ch[id + 1]))                                                                a[i + 1] = 1;                                                }                                                else {                                                        cnt = cnt + res - 2;                                                        i = id;                                                }                                        }                                        else if(cnt == 2) {                                                a[i] = 1;                                                if(res >= 3) {                                                        cnt = 0;                                                        i = id;                                                        if(!get_(ch[id + 1]))                                                        a[i + 1] = 1;                                                }                                                else {                                                        cnt = res + cnt - 2;                                                        i = id;                                                }                                        }                                }                        }                }        }        for(int i = 0; i < len; i++) {                if(a[i]) printf(" ");                printf("%c", ch[i]);        }        printf("\n");        return 0;}