Unnatural Language Processing

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) (1t100) — 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) (1n2105) — 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 2105.

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;
}
  • 17
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Pretty Boy Fox

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值