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
hellno
Output
hell no 
Input
abacaba
Output
abacaba 
Input
asdfasdf
Output
asd fasd f 

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

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

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
const int N=3e3;
int n;
int a[N+],is[];
char s[N+];
int main(void)
{
is['a']=is['e']=is['i']=is['o']=is['u']=;
cin>>(s+);
n=strlen(s+);
int cnt=;
for(int i=;i<=n;i++)
{
if(!is[s[i]])
{
cnt++;
if(cnt>=)
{
bool ok=true;
int j=max(,i-);
for(int k=j;k<=i-;k++)//前面的3个都和它一样吗
if(s[k]!=s[i])
ok=false;
if(ok)//如果是的话
{
cout<<s[i];
int k=i;
while(k+<=n&&s[k+]==s[i])//往后一直找和它一样的
{
k++;
cout<<s[k];
}
cnt=;
i=k;//cnt变成2了,指向下一个。
}
else//不是的话。只能分割了。
{
cout<<' '<<s[i];
cnt=;
}
}
else
cout<<s[i];//没3个
}
else//是元音直接输出
{
cout<<s[i];
cnt=;
}
}
//连续出现
}

Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861C Did you mean...【字符串枚举,暴力】的更多相关文章

  1. Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861B Which floor?【枚举,暴力】

    B. Which floor? time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

  2. Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861A k-rounding【暴力】

    A. k-rounding time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  3. Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)

    A. k-rounding 题目意思:给两个数n和m,现在让你输出一个数ans,ans是n倍数且末尾要有m个0; 题目思路:我们知道一个数末尾0的个数和其质因数中2的数量和5的数量的最小值有关系,所以 ...

  4. 【模拟】 Codeforces Round #434 (Div. 1, based on Technocup 2018 Elimination Round 1) C. Tests Renumeration

    题意:有一堆数据,某些是样例数据(假设X个),某些是大数据(假设Y个),但这些数据文件的命名非常混乱.要你给它们一个一个地重命名,保证任意时刻没有重名文件的前提之下,使得样例数据命名为1~X,大数据命 ...

  5. Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)

    A. Search for Pretty Integers 题目链接:http://codeforces.com/contest/872/problem/A 题目意思:题目很简单,找到一个数,组成这个 ...

  6. Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) D. Something with XOR Queries

    地址:http://codeforces.com/contest/872/problem/D 题目: D. Something with XOR Queries time limit per test ...

  7. Codeforces Round #440 (Div. 1, based on Technocup 2018 Elimination Round 2) C - Points, Lines and Ready-made Titles

    C - Points, Lines and Ready-made Titles 把行列看成是图上的点, 一个点(x, y)就相当于x行 向 y列建立一条边, 我们能得出如果一个联通块是一棵树方案数是2 ...

  8. Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) C. Maximum splitting

    地址: 题目: C. Maximum splitting time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. ACM-ICPC (10/15) Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)

    A. Search for Pretty Integers You are given two lists of non-zero digits. Let's call an integer pret ...

随机推荐

  1. 【java API基本实现】ArrayList

    ArrayList: package com.tn.arraylist; public class ArrayList { Object[] objects=new Object[10]; int i ...

  2. 【python】递归(阶乘、斐波纳契、汉诺塔)

  3. for循环语句以及输出语句

    action() { int  i;  //定义变量    lr_start_transaction("submit_answer");  //开始事物    for(i=0; i ...

  4. ImportError: No module named 'request'

    使用系统自带的Python 2.7执行python时出现ImportError: No module named 'request'这样的报错,这是系统自带的Python没有requests库,这里可 ...

  5. Wincc flexable的IO域组态

    1.题目 2.新建三个变量 3.组态画面,添加IO域1 1)常规设置 2)属性设置 4.组态IO域2 1)常规项 2)属性设置 5.组态第三个IO域 1)常规设置 2)属性设置 6.此外可以设置动画 ...

  6. bat获取系统时间修改系统密码

    @echo off %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe&q ...

  7. uniq 命令详解

    作用: 报告或忽略文件中的重复行,一般与sort 连用. 选项:-c count 在每列前显示该行重复出现的次数     -d repeated, 仅显示重复出现的行列     -f skip fie ...

  8. 7.nginx伪静态规则

    网上收集的一些常用的,要用的时候就仿照一下,或直接拿来用. WordPress伪静态规则 location / { index index.html index.php; if (-f $reques ...

  9. volatile作用及相关集合类

    在工作一年多之后,java程序员都会了解到volatile 这个修饰符, 其在多线程环境下解决了long/double写操作的原子性.基本变量的可见性.通过建立内存屏障保证指令有序性 那么在哪些Jav ...

  10. Error in library(DESeq2) : 不存在叫‘DESeq2’这个名字的程辑包

    Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type&quo ...