Unnatural Language Processing
Problem
Lura was bored and decided to make a simple language using the five letters a, b, c, d, e. There are two types of letters:
- vowels — the letters a and e. They are represented by V.
- consonants — the letters b, c, and d. They are represented by C.
There are two types of syllables in the language: CV (consonant followed by vowel) or CVC
(vowel with consonant before and after). For example, ba, ced, bab are syllables, but aa, eda, baba are not.
A word in the language is a sequence of syllables. Lura has written a word in the language, but she doesn’t know how to split it into syllables. Help her break the word into syllables.
For example, given the word bacedbab, it would be split into syllables as ba.ced.bab
(the dot . represents a syllable boundary).
Input
The input consists of multiple test cases. The first line contains an integer t t t ( 1 ≤ t ≤ 100 ) (1≤t≤100) (1≤t≤100) — the number of test cases. The description of the test cases follows.
The first line of each test case contains an integer n n n ( 1 ≤ n ≤ 2 ⋅ 1 0 5 ) (1≤n≤2⋅10^5) (1≤n≤2⋅105) — the length of the word.
The second line of each test case contains a string consisting of n lowercase Latin characters — the word.
All words given are valid words in the language; that is, they only use the letters a, b, c, d, e, and each word is made up of several syllables.
The sum of n over all test cases does not exceed 2 ⋅ 1 0 5 2⋅10^5 2⋅105.
Output
For test case, output a string denoting the word split into syllables by inserting a dot .
between every pair of adjacent syllables.
If there are multiple possible splittings, output any of them. The input is given in such a way that at least one possible splitting exists.
Example
Input
6
8
bacedbab
4
baba
13
daddecabeddad
3
dac
6
dacdac
22
dababbabababbabbababba
Output
ba.ced.bab
ba.ba
dad.de.ca.bed.dad
dac
dac.dac
da.bab.ba.ba.bab.bab.ba.bab.ba
Code
// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <sstream>//整型转字符串
// #include <stack>//栈
// #include <deque>//堆/优先队列
// #include <queue>//队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+10;
ll a[N];
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
string s;
cin>>n>>s;
for(ll i=0;i<n;i++)
{
if(n-i<4) cout<<s[i];
else if(s[i]=='b'||s[i]=='c'||s[i]=='d')
{
cout<<s[i]<<s[i+1];
if(s[i+3]=='a'||s[i+3]=='e') cout<<".",i++;
else cout<<s[i+2]<<".",i+=2;
}
}
cout<<endl;
}
return 0;
}