Did you mean...(模拟+条件判断)

Beroffice 文本编辑器

Did you mean…

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

hellno

Output

hell no 

Input

abacaba

Output

abacaba 

Input

asdfasdf

Output

asd fasd f 
题意:

一个错误的单词是连续的辅音块中存在三个或以上的辅音字母(如果这些辅音字母是相同的除外),现在我们想用最少的空格将单词分为多个合理的子单词,输出分隔以后的结果。

分析:

从前往后贪心就可以了,为了让空格输出尽量少,只需要从每个极限后面输出空格即可

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 3005;
char c[] = "aeiou";
char s[maxn];
inline bool check(char ch){
    for(int i = 0; i <= 4; i++)
        if(ch == c[i]) return 0;
    return 1;
}
int main(){
    scanf("%s",s);
    int n = strlen(s);
    int lst = -1;//记录上一个输出空格的位置,避免两个连续空格
    for(int i = 0; i <= n-1; i++){
        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;
        }
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值