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

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代码:

 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 }

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏大内老A

通过实例模拟ASP.NET MVC的Model绑定机制:数组

[续《通过实例模拟ASP.NET MVC的Model绑定机制:简单类型+复杂类型]》]基于数组和集合类型的Model绑定机制比较类似,对于绑定参数类型或者参数类...

2969
来自专栏恰童鞋骚年

.NET中那些所谓的新语法之二:匿名类、匿名方法与扩展方法

开篇:在上一篇中,我们了解了自动属性、隐式类型、自动初始化器等所谓的新语法,这一篇我们继续征程,看看匿名类、匿名方法以及常用的扩展方法。虽然,都是很常见的东西,...

1223
来自专栏技术博客

设计模式之三(工厂方法模式)

工厂方法模式:定义一个用于创建对象的接口,让子类决定实例化那一个类。工厂方法使一个类的实例化延迟到其子类。

1652
来自专栏jessetalks

由浅入深表达式树(一)创建表达式树

  为什么要学习表达式树?表达式树是将我们原来可以直接由代码编写的逻辑以表达式的方式存储在树状的结构里,从而可以在运行时去解析这个树,然后执行,实现动态的编辑和...

3274
来自专栏vue

委托初级篇——lambda表达式的推导

 public delegate void ConsoleWriteStr(string name,DateTime now);

1572
来自专栏desperate633

Java Comparable 与 Comparator

在收集对象之后,对象的排序是经常需要用到的操作。但我们不需要亲自实现各种排序算法,java.util.Collections提供了sort方法,List作为一种...

711
来自专栏小狼的世界

Python获取数字的二进制值

Convert an integer number to a binary string prefixed with “0b”. The result is a...

1271
来自专栏非著名程序员

常见面试题六之java系列

做Android开发最重要的是要有一个很好的java基础。所以在我们的面试过程中也会被经常问到有关java的问题,其实在小编看来,如果java基础不好,那开发起...

1936
来自专栏hbbliyong

C#基础知识回顾--线程传参

  在不传递参数情况下,一般大家都使用ThreadStart代理来连接执行函数,ThreadStart委托接收的函数不能有参数, 也不能有返回值。如果希望传递参...

2896
来自专栏GreenLeaves

C#核编之格式化编程

一、格式化控制台输入输出     1、 在前面的随笔中,会经常看到诸如{0},{1}之类的标记嵌入在字符串变量中。.NET引入一种字符串格式化的新风格。与C的p...

19610

扫码关注云+社区

领取腾讯云代金券