Accepted
Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ll tc;
cin>>tc;
while(tc--)
{
string s;
cin>>s;
deque<char>dq;
for(int i=0;i<s.size();i++)
dq.push_back(s[i]);
ll q;
cin>>q;
ll c=0;
while(q--)
{
ll x;
cin>>x;
if(x==1)
{
c++;
}
else
{
ll y;
cin>>y;
char ch;
cin>>ch;
if(y==1)
{
if(c%2==0)
dq.push_front(ch);
else
dq.push_back(ch);
}
else
{
if(c%2==0)
dq.push_back(ch);
else
dq.push_front(ch);
}
}
}
if(c%2==0){
for(auto it:dq)
cout<<it;
cout<<endl;}
else
{
for(int i=dq.size()-1;i>=0;i--)
cout<<dq[i];
cout<<endl;
}
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1088 Mr. Heart's String Challenge
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-09-05 20:19:03
- Judged At
- 2024-11-11 02:57:05
- Judged By
- Score
- 100
- Total Time
- 410ms
- Peak Memory
- 8.336 MiB