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. 彻底搞定C指针--“函数名与函数指针”

    函数名与函数指针   一 通常的函数调用 一个通常的函数调用的例子: //自行包含头文件 void MyFun(int x); //此处的申明也可写成:void MyFun( int ); 点击打开链 ...

  2. python flask豆瓣微信小程序案例

    项目步骤 定义首页模板index.html <!DOCTYPE html> <html lang="en"> <head> <meta c ...

  3. strak组件(8):基本增删改查实现及应用和排序

    效果图: 新增函数: def reverse_common_url(self, name, *args, **kwargs) 反向生成url,需要传增删改的url作为参数,携带原参数 def reve ...

  4. c++ function和bind

    bind 定义在头文件 functional 里 template<typename _Func, typename... _BoundArgs> inline typename _Bin ...

  5. 如何查询进程中占用CPU的线程

    top -c             命令查找进程PID top -Hp PID          找进程中的线程号 echo %x 线程号   将线程转换成16进制 jstack PID |grep ...

  6. POJ:2236-Wireless Network

    Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 34265 Accepted: 14222 D ...

  7. J2EE中getParameter与getAttribute以及对应的EL表达式

    摘自http://blog.csdn.net/woshixuye/article/details/8027089 getParameter ① 得到的都是String类型的.如http://name. ...

  8. c语言的左移、右移

    先说左移,左移就是把一个数的所有位都向左移动若干位,在C中用<<运算符.例如: int i = 1; i = i << 2;  //把i里的值左移2位 也就是说,1的2进制是0 ...

  9. ElasticSearch学习笔记(三)-- 查询

    1. URISearch详解与演示 2. QueryDSL简介 3. 字段类查询简介及match-query 4. 相关性算分 5. match-phrase-query 6. query-strin ...

  10. quartz 动态更改执行时间

    说明:Quartz + Servlet, 参考国外著名站点的文章:http://stackoverflow.com/questions/12208309/need-to-set-the-quartz- ...