Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void solve() {
string str;
cin>>str;
int q;
cin>>q;
deque<char> deq(str.begin(),str.end());
bool rf=false;
while(q--){
int type;
cin>>type;
if(type==1){
rf=true;
}
else if(type==2){
int d;cin>>d;
char c;cin>>c;
if(rf){
if(d==1){
deq.push_back(c);
}
else{
deq.push_front(c);
}
}
else{
if(d==1){
deq.push_front(c);
}
else{
deq.push_back(c);
}
}
}
}
if(rf)reverse(deq.begin(),deq.end());
for(auto ch: deq){
cout<<ch;
}
cout<<endl;
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1088 Mr. Heart's String Challenge
- Contest
- Brain Booster #5
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-09-05 16:29:20
- Judged At
- 2024-11-11 03:00:31
- Judged By
- Score
- 5
- Total Time
- 700ms
- Peak Memory
- 3.441 MiB