A. Word Correction
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.

Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consecutive vowels in the word, it deletes the first vowel in a word such that there isanother vowel right before it. If there are no two consecutive vowels in the word, it is considered to be correct.

You are given a word s. Can you predict what will it become after correction?

In this problem letters a, e, i, o, u and y are considered to be vowels.

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the number of letters in word s before the correction.

The second line contains a string s consisting of exactly n lowercase Latin letters — the word before the correction.

Output

Output the word s after the correction.

Examples
input

Copy
5
weird
output
werd
input

Copy
4
word
output
word
input

Copy
5
aaeaa
output
a
Note

Explanations of the examples:

  1. There is only one replace: weird  werd;
  2. No replace needed since there are no two consecutive vowels;
  3. aaeaa  aeaa  aaa  aa  a.

题目大意:给一个字符串,如果有两个连续的元音字母,则删掉后一个,一直进行这种操作,求最后的字符串.

分析:一个一个去枚举删就比较麻烦了,一个比较好的做法是用栈维护,枚举第i个位置,与栈顶的字符比较,看是否符合要求.最后输出栈里的字符串就好了.

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <cmath> using namespace std; typedef long long LL; char s[],ans[];
int tot,n; bool check(char a,char b)
{
bool flag1 = false,flag2 = false;
if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y')
flag1 = true;
if (b == 'a' || b == 'e' || b == 'i' || b == 'o' || b == 'u' || b == 'y')
flag2 = true;
if (flag1 && flag2)
return true;
return false;
} int main()
{
scanf("%d",&n);
scanf("%s",s + );
for (int i = ; i <= n; i++)
{
if (!tot)
ans[++tot] = s[i];
else
{
if (!check(ans[tot],s[i]))
ans[++tot] = s[i];
}
}
for (int i = ; i <= tot; i++)
printf("%c",ans[i]); return ;
}

Codeforces 938.A Word Correction的更多相关文章

  1. Codeforces 938 D. Buy a Ticket (dijkstra 求多元最短路)

    题目链接:Buy a Ticket 题意: 给出n个点m条边,每个点每条边都有各自的权值,对于每个点i,求一个任意j,使得2×d[i][j] + a[j]最小. 题解: 这题其实就是要我们求任意两点的 ...

  2. Codeforces 938.D Buy a Ticket

    D. Buy a Ticket time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  3. Codeforces 938.C Constructing Tests

    C. Constructing Tests time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. Codeforces 938.B Run For Your Prize

    B. Run For Your Prize time limit per test 1 second memory limit per test 256 megabytes input standar ...

  5. Codeforces 938 正方形方格最多0/1 足球赛dijkstra建图

    A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...

  6. CF938A Word Correction 题解

    Content 有一个长度为 \(n\) 的,只包含小写字母的字符串,只要有两个元音字母相邻,就得删除后一个元音字母(\(\texttt{a,e,i,o,u,y}\) 中的一个),请求出最后得到的字符 ...

  7. Educational Codeforces Round 38 (Rated for Div. 2)

    这场打了小号 A. Word Correction time limit per test 1 second memory limit per test 256 megabytes input sta ...

  8. 【Educational Codeforces Round 38 (Rated for Div. 2)】 Problem A-D 题解

    [比赛链接] 点击打开链接 [题解] Problem A Word Correction[字符串] 不用多说了吧,字符串的基本操作 Problem B  Run for your prize[贪心] ...

  9. CodeForces 176B Word Cut dp

    Word Cut 题目连接: http://codeforces.com/problemset/problem/176/C Description Let's consider one interes ...

随机推荐

  1. django+xadmin在线教育平台(七)

    4-3 新建项目 Python2.7 创建虚拟环境. mkvirtualenv mxonline2 安装django pip install django==1.9.8 注意Python2下此处必须用 ...

  2. IBM Rational Software Architect V9.0安装图解

    IBM Rational Software Architect(RSA) -- IBM软件开发平台的一部分 – 是IBM在2003年二月并购Rational以来,首次发布的Rational产品.改进过 ...

  3. python中函数的不定长参数

    例1: #定义一个含有不定长参数的函数,本例第三个参数*args def sum_nums(a,b,*args): print('_'*30) print(a) print(b) print(args ...

  4. Git ---游离状态下的commit 分支切换与找回,commit之后无法找到历史记录

    commit之后无法找到历史记录 https://blog.csdn.net/zyb2017/article/details/78307688

  5. Git-改变历史

    悔棋 在日常的Git操作中,会经常出现这样的状况,输入git commit命令刚刚敲下回车键就后悔了:可能是提交说明中出现了错别字,或者有文件忘记提交,或者有的修改不应该提交,诸如此类. Git提供了 ...

  6. 万年历Calendar、js修改日期

    //万年历 Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE,-1); //改变日期,改变年份.月份类似 SimpleDateF ...

  7. laravel5.5契约

    无规矩不成方圆, Laravel 的契约是一组定义框架提供的核心服务的接口,规定了实现该接口的规范. 为什么要使用接口 首先,让我们来看一些高耦合缓存实现的代码.如下: <?php namesp ...

  8. 实际遭遇GC回收造成的Web服务器CPU跑高

    今天下午有段时间访问园子感觉不如以前那么快的流畅,上Web服务器一看,果然,负载均衡中的1台云服务器CPU跑高. 上图中红色曲线表示的是CPU占用率.正常情况下,CPU占用率一般在40%以下. 这台云 ...

  9. 每天一个Linux命令(1):cd命令

    cd命令用来切换工作目录至dirName,其中dirName表示绝对路径或相对路径.若目录名称省略,则切换至使用者的home directory(也就是钢login时所在的目录).另外,~ 也表示ho ...

  10. 解决ubuntu发热严重的问题

    对于双显卡PC安装ubuntu ,风扇狂转,发热严重,原因基本双显卡的优化导致. 解决具体步骤如下: 命令行输入sudo apt-get install bumblebee bumblebee-nvi ...