Getting TLE in O(n) solution

This is the solution of Vowel anxiety Starter 46 where in contest i did the same which was told in editorial but i am getting TLE. I am posting the link

https://www.codechef.com/viewsolution/68418262

Please do not focus on code quality

Try this
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define debug cout<<“Here\n”
void solve(){
ll n,i;
string s,a="",ans="";
cin>>n;
cin>>s;
map<char,ll> count;
count[‘a’]=1;
count[‘e’]=1;
count[‘i’]=1;
count[‘o’]=1;
count[‘u’]=1;
// vector v;
deque q;
ll cnt=0;
for(i=0;i<n;i++){
if(count[s[i]] == 0){
a+=s[i];
if(cnt%2 == 0){
q.pb(s[i]);
}
else{
q.push_front(s[i]);
}
// i++;
}
else{
if(a!=""){
cnt++;
}
a=s[i];
if(cnt%2 == 0){
q.pb(s[i]);
}
else{
q.push_front(s[i]);
}
}
}
if(cnt%2 == 0){
while(!q.empty()){
ans+=q.front();
q.pop_front();
}
}
else{
while(!q.empty()){
ans+=q.back();
q.pop_back();
}
}
cout<<ans<<"\n";
return;
}
int main(){
ll t;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>t;
while(t–){
solve();
}
}