题目描述
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 is another 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.
输入
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 the word s after the correction.
样例
inputCopy
5
weird
output
werd
inputCopy
4
word
output
word
inputCopy
5
aaeaa
output
a
题意
把CD写完迷迷糊的这个辣鸡题不想写了,,,,
记录每个连续元音字母位置即可
AC代码
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define CLR(a,b) memset(a,(b),sizeof(a))
const int MAXN = 1e6;
const int INF = 0x3f3f3f3f;
const LL INFLL = ~0ull>>1;
char ch[] = {'a', 'e', 'i', 'o', 'u','y'};
bool check(char ss)
{
for(int i = 0; i < 6; i++)
if(ss == ch[i])
return true;
return false;
}
vector<int> v;
int main()
{
ios::sync_with_stdio(false),cin.tie(0);
int n;
string s;
cin >> n >> s;
bool flag = false;
for(int i = 0; i < n; i++) {
if(i > 0)
if(check(s[i]) && check(s[i-1])) {
v.push_back(i); flag = true;
}
}
if(!flag) return cout << s << endl,0;
for(int i=0,j=0; i < n; i++) {
if(i == v[j])
j++;
else
cout << s[i];
}
return 0;
}