Accepted
Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
string s;
cin>>s;
int q;
cin>>q;
long long rev=0;
string left;
string right;
for(int i=0;i<q;i++)
{
long long input;
cin>>input;
long long hey;
char ch;
if(input==2)
{
cin>>hey;
cin>>ch;
}
if(input==1)
{
rev++;
}
else if(input==2)
{
if(rev%2==0)
{
if(hey==1)
left.push_back(ch);
else
right.push_back(ch);
}
else
{
if(hey==2)
left.push_back(ch);
else
right.push_back(ch);
}
}
}
if(rev%2==0)
{
reverse(left.begin(),left.end());
cout<<left;
cout<<s;
cout<<right<<endl;
}
else
{
reverse(right.begin(),right.end());
cout<<right;
reverse(s.begin(),s.end());
cout<<s;
cout<<left<<endl;
}
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1088 Mr. Heart's String Challenge
- Contest
- Brain Booster #5
- Language
- C++11 (G++ 13.2.0)
- Submit At
- 2024-09-05 16:20:03
- Judged At
- 2024-10-03 13:07:55
- Judged By
- Score
- 100
- Total Time
- 685ms
- Peak Memory
- 8.113 MiB