CF

来源:互联网 发布:易语言qq飞车辅助源码 编辑:程序博客网 时间:2024/05/16 04:13

1.题目描述:

K. Stepan and Vowels
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Stepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa".

Sergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are "a", "e", "i", "o", "u" and "y".

There are exceptions: if letters "e" or "o" repeat in a row exactly 2 times, like in words "feet" and "foot", the program must skip them and do not transform in one vowel. For example, the word "iiiimpleeemeentatiioon" must be converted to the word "implemeentatioon".

Sergey is very busy and asks you to help him and write the required program.

Input

The first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.

The second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.

Output

Print the single string — the word written by Stepan converted according to the rules described in the statement.

Examples
input
13pobeeeedaaaaa
output
pobeda
input
22iiiimpleeemeentatiioon
output
implemeentatioon
input
18aeiouyaaeeiioouuyy
output
aeiouyaeeioouy
input
24aaaoooiiiuuuyyyeeeggghhh
output
aoiuyeggghhh

2.题意概述:

给你一堆字符串,要你合并元音部分a e i o u y,特殊的是ee和oo连续出现两次则不合并。

3.解题思路:

直接模拟o(n)扫一遍,边扫边计数,特判如果是e和o且计数为2则输出原对。

这题reject到绝望,最后用GCC交的,现在发现会java和C#的大佬有多爽,看来学语言真是多多益善。

4.AC代码:

#include <stdio.h>#include <string.h>#include <math.h>#include <time.h>#define INF 0x3f3f3f3f#define maxn 100100#define N 1111#define eps 1e-6#define pi acos(-1.0)#define e exp(1.0)const int mod = 1e9 + 7;typedef long long ll;typedef unsigned long long ull;char ch[maxn];int main(){#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);long _begin_time = clock();#endifint n;while (~scanf("%d%s", &n, ch)){for (int i = 0; i < n; i++){char cur = ch[i];if (cur == 'a' || cur == 'i' || cur == 'u' || cur == 'y'){printf("%c", cur);while (ch[i] == cur)i++;if (i == n)break;i--;continue;}else if (cur == 'e' || cur == 'o'){int cnt = 0;printf("%c", cur);while (ch[i] == cur){i++;cnt++;}if (cnt == 2)printf("%c", cur);if (i == n)break;i--;continue;}elseprintf("%c", cur);}puts("");}#ifndef ONLINE_JUDGElong _end_time = clock();printf("time = %ld ms.", _end_time - _begin_time);#endifreturn 0;}

0 0
原创粉丝点击