Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
void solve()
{
string s;
cin>>s;
int q;
cin>>q;
deque<char>f;
deque<char>b;
bool r=false;
for (int i=0; i<q; ++i){
int ty;
cin>>ty;
if(ty==1){
r=!r;
}
else if(ty==2){
int d;
char c;
cin>>d>>c;
if(d==1){
if(!r){
f.push_front(c);
}
else{
b.push_back(c);
}
}
else if(d==2){
if(!r){
b.push_back(c);
}
else{
f.push_front(c);
}
}
}
}
if(!r){
for(char ch:s){
b.push_front(ch);
}
}
else{
for(char ch:s){
f.push_back(ch);
}
}
if(r){
for(auto it=f.rbegin(); it!=f.rend(); ++it){
cout << *it;
}
for(char ch:b){
cout<<ch;
}
}
else{
for(char ch:b){
cout<<ch;
}
for(char ch:f){
cout<<ch;
}
}
cout<<endl;
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1088 Mr. Heart's String Challenge
- Contest
- Brain Booster #5
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-09-05 17:35:59
- Judged At
- 2024-10-03 13:03:05
- Judged By
- Score
- 5
- Total Time
- 682ms
- Peak Memory
- 9.289 MiB