Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861C Did you mean...【字符串枚举,暴力】
C. 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.
The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.
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.
hellno
hell no
abacaba
abacaba
asdfasdf
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...【字符串枚举,暴力】的更多相关文章
- 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 ...
- 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 ...
- 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的数量的最小值有关系,所以 ...
- 【模拟】 Codeforces Round #434 (Div. 1, based on Technocup 2018 Elimination Round 1) C. Tests Renumeration
题意:有一堆数据,某些是样例数据(假设X个),某些是大数据(假设Y个),但这些数据文件的命名非常混乱.要你给它们一个一个地重命名,保证任意时刻没有重名文件的前提之下,使得样例数据命名为1~X,大数据命 ...
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)
A. Search for Pretty Integers 题目链接:http://codeforces.com/contest/872/problem/A 题目意思:题目很简单,找到一个数,组成这个 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- The Movie db (TMDB)的API申请
在共享API TMDB中申请时,一只报错Application summary please elaborate on how you plan to use our API,我是用汉字描述的,开始以 ...
- ArcGIS API for JavaScript 4.2学习笔记[11] 官方第五章Popups(弹窗)概览与解释
直接跳过第三第四章了,第三章Layer和第四章可视化,怎么说呢,Layer是组织数据的,是Map的属性之一.可视化属于符号化编程,暂时不看. 第五章是对数据.结果的显示,类似于alert()..NET ...
- bzoj 2750: [HAOI2012]Road
Description C国有n座城市,城市之间通过m条单向道路连接.一条路径被称为最短路,当且仅当不存在从它的起点到终点的另外一条路径总长度比它小.两条最短路不同,当且仅当它们包含的道路序列不同.我 ...
- 多线程下QAxObject指针为NULL的解决办法
项目中需要对Excel进行操作,把数据中的数据写入到Excel文件中.在数据量大的情况下,操作Excel是一件费时的操作. 但是执行到下列代码时就会出现空指针的情况: QAxObject *excel ...
- DES加解密、JavaScript、Java
JavaScript代码 DES.js /** * Created by Andy on 2017/11/30. */ /** * DES加密/解密 * @Copyright Copyright ...
- Android studio Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to
http://blog.csdn.net/FlyRabbit_1/article/details/74536317 Error:org.gradle.api.internal.tasks.Defaul ...
- sql sever基本查询语句
查询(*可代表全部)(<>代表不等于于)select 列名 from 表名(,隔开)where 查询条件order by 排序的列名+连接的数据类型必须兼容(结果为字符串数据的连接 , 如 ...
- MySQL查询(进阶)(每个标点都是重点)
MySQL 是工作中很普遍的需要用到的,所以必须掌握,而 之前我们一直说的都是怎么存. 你只会存不会取有个屁用.所以希望大家在如何查询读取数据这方面多下点功夫. 这篇和上一篇都是干货,我也是第一次学. ...
- Java容器---Map基础
1.Map API (1)Map 集合类用于存储元素对(称作"键"和"值"),其中每个键映射到一个值. java.util Interface Map<K ...
- golang 数组反转
我做hackerearth上题目记录,具体的题目描述是这样的: Given the size and the elements of array A, print all the elements i ...