/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 117ms 3.262 MiB
#4 Accepted 69ms 7.711 MiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 128ms 2.293 MiB
#7 Accepted 119ms 2.238 MiB
#8 Accepted 25ms 1.02 MiB
#9 Accepted 91ms 8.027 MiB
#10 Accepted 115ms 7.926 MiB
#11 Accepted 38ms 3.672 MiB
#12 Accepted 77ms 7.328 MiB

Code

/* SRIJON
        SINGHA
            SAMANTA */
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define nl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define yes cout << "YES" << nl
#define no cout << "NO" << nl
#define fi first
#define sec second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
const int mod = 1e9 + 7;

int32_t main()
{
    FIO

    ll t;	cin >> t;
    ll tt=t;
    while (tt--)
    {
        string s;   cin>>s;
        deque<char>dq;
        for(ll i=0;i<s.size();i++)  dq.pb(s[i]);
                       
        ll q;   cin>>q;
        bool flag=true;
        while(q--)
        {
            ll op;  cin>>op;
            if(op==1)
            {
                if(flag) flag=false;
                else flag=true;
            }
            else
            {
                ll se;  cin>>se;
                char c; cin>>c;
                if(se==1)
                {
                    if(flag) dq.pf(c);
                    else dq.pb(c);
                }
                else
                {
                    if(flag) dq.pb(c);
                    else    dq.pf(c);
                }
            }
        }
        if(flag)
        {
            for(ll i=0;i<dq.size();i++)
            {
                cout<<dq[i];         
            }
        }
        else
        {
            for(ll i=dq.size()-1;i>=0;i--)
            {
                 cout<<dq[i];          
            }
        }
        cout<<nl;      
    }

    return 0;
}

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 16:15:40
Judged At
2024-09-05 16:15:40
Judged By
Score
100
Total Time
128ms
Peak Memory
8.027 MiB