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. Linux文件服务器实战(匿名用户)

    一.进程与线程 二.vsftp服务器 1.文件传输协议(file transfer protocol,FTP) 基于该协议ftp客户端和服务端实现文件共享,上传下载文件 FTP基于TCP协议生成一个虚 ...

  2. udp回显客户端发送的数据

    这里让客户端给服务端发送的数据被服务端自动发回来 客户端: import socket client_socket = socket.socket(socket.AF_INET, socket.SOC ...

  3. H5之audio标签放音兼容所有浏览器方法

    前端交流群,群文件提供大量文档.书籍和资料.期待你的加入!群号:127768464 由于项目需要,最近刚做了一个网页放音的功能,使用到了H5新标签<audio></audio> ...

  4. java-访问控制修饰符

    访问权限 public    任何情况都可以访问 默认包 本包范围内可以访问到 protect       同一个包里的所有类所可以访问:所有子类(子类可以不和父类在同一个包)都可以访问 privat ...

  5. 在ubuntu上安装subline

    Sublime Text is a most popular, lightweight and smart cross-platform text and source code editor wit ...

  6. PPT入门学习笔记1:待修改

    一直被比人忽悠实在是累了,我可以接受自己的失误,但我接受不了别人一次又一次的坑我! 做PPT的原则是什么? 1.一个目标: "一个PPT只为一类人服务,针对不同的听众制作不同层次内容的PPT ...

  7. 【笔记】objdump命令的使用

    ---恢复内容开始--- objdump命令是Linux下的反汇编目标文件或者可执行文件的命令,它还有其他作用,下面以ELF格式可执行文件test为例详细介绍: objdump -f test 显示t ...

  8. proteus中蜂鸣器不响的原因

        本文参考自https://blog.csdn.net/gin_love/article/details/51168369 此网站.在用proteus仿真报警电路时,发现蜂鸣器不响.后在网上找了 ...

  9. POJ:1222-EXTENDED LIGHTS OUT(矩阵反转)

    EXTENDED LIGHTS OUT Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12956 Accepted: 8186 ...

  10. Mysql处理海量数据时的一些优化查询速度方法【转】

    最近一段时间由于工作需要,开始关注针对Mysql数据库的select查询语句的相关优化方法.由于在参与的实际项目中发现当mysql表的数据量达到百万级时,普通SQL查询效率呈直线下降,而且如果wher ...