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

时间:2023-02-16 18:28:25

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 &num;434 &lpar;Div&period; 2&comma; based on Technocup 2018 Elimination Round 1&rpar;&amp&semi;&amp&semi;Codeforces 861B Which floor&quest;【枚举,暴力】

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

  2. Codeforces Round &num;434 &lpar;Div&period; 2&comma; based on Technocup 2018 Elimination Round 1&rpar;&amp&semi;&amp&semi;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 &num;434 &lpar;Div&period; 2&comma; based on Technocup 2018 Elimination Round 1&rpar;

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

  4. 【模拟】 Codeforces Round &num;434 &lpar;Div&period; 1&comma; based on Technocup 2018 Elimination Round 1&rpar; C&period; Tests Renumeration

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

  5. Codeforces Round &num;440 &lpar;Div&period; 2&comma; based on Technocup 2018 Elimination Round 2&rpar;

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

  6. Codeforces Round &num;440 &lpar;Div&period; 2&comma; based on Technocup 2018 Elimination Round 2&rpar; D&period; Something with XOR Queries

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

  7. Codeforces Round &num;440 &lpar;Div&period; 1&comma; based on Technocup 2018 Elimination Round 2&rpar; C - Points&comma; Lines and Ready-made Titles

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

  8. Codeforces Round &num;440 &lpar;Div&period; 2&comma; based on Technocup 2018 Elimination Round 2&rpar; C&period; Maximum splitting

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

  9. ACM-ICPC &lpar;10&sol;15&rpar; Codeforces Round &num;440 &lpar;Div&period; 2&comma; based on Technocup 2018 Elimination Round 2&rpar;

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

随机推荐

  1. vtkTubeFilter实例

    filter that generates tubes around lines vtkTubeFilter is a filter that generates a tube around each ...

  2. 安装Java的IDE Eclipse时出现java&period;net&period;SocketException&comma;出现错误Installer failed,show&period;log

    ERROR: org.eclipse.equinox.p2.transport.ecf code=1002 Unable to read repository at http://download.e ...

  3. 使用Architecture Explorer分析应用程序及使用层次图

    使用Architecture Explorer分析应用程序 Architecture Explorer和依赖图可以帮助我们了解所有的项目,包括小项目和大项目.Architecture Explorer ...

  4. Hibernate 抓取策略fetch-1 &lpar;select join subselect&rpar;

    原文 :http://4045060.blog.51cto.com/4035060/1088025 部分参考:http://www.cnblogs.com/rongxh7/archive/2010/0 ...

  5. JPages分页插件的使用

    废话不多说,直接上代码. 首先下载JPages的js和css包,附上下载地址:http://dl.oschina.net/softfile/jpages/jpages-latest-138554713 ...

  6. Umbraco Form需要引用些客户端dependencies &lpar;jquery&rpar;

    Preparing your frontend In order to work correctly Umbraco Forms needs some client dependencies, bei ...

  7. Panel&lpar; 面板&rpar; 组件 上

    一. 加载方式//class 加载方式<div class="easyui-panel" data-options="closable:true"titl ...

  8. 我的小OJ

    NCOJ 欢迎大家来瓷瓷.出题哦QwQ 嗯,没了.

  9. 无状态http协议上用户的身份认证

    1.注册时可以使用手机短信验证码进行身份认证 2.用户每次请求不能每次都发送验证码,这时需要服务器给客户端颁发一个身份凭证(一般为一个唯一的随机数),用户每次请求时都携带身份凭证, 服务器会记录该身份 ...

  10. CDQ分治小结

    CDQ分治小结 warning:此文仅用博主复习使用,初学者看的话后果自负.. 复习的时候才发现以前根本就没写过这种东西的总结,简单的扯一扯 cdq分治的经典应用就是解决偏序问题 比如最经典的三维偏序 ...