/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 612.0 KiB
#3 Accepted 110ms 3.375 MiB
#4 Accepted 24ms 8.316 MiB
#5 Accepted 1ms 540.0 KiB
#6 Accepted 121ms 2.742 MiB
#7 Accepted 118ms 2.461 MiB
#8 Accepted 22ms 1.445 MiB
#9 Accepted 43ms 8.887 MiB
#10 Accepted 65ms 7.922 MiB
#11 Accepted 28ms 3.902 MiB
#12 Accepted 29ms 8.105 MiB

Code

/*Rabbi Zidni Eilmaa*/

// We are open. We are looking for SHOTRUJ...
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpl;
typedef set<ll> sll;
typedef map<ll,ll> mll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
#define debug(x) cout<<#x<<" "<<x<<endl;
#define loop for(int i=1; i<=n; i++)
#define all(a) (a).begin(), (a).end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define forn(i, n) for(int i=1; i<=(int)n; i++)
#define ANS cout << ans << "\n"
#define PY cout << "YES\n"
#define PN cout << "NO\n" 

int mod = 1e9 + 7;

void init(){
    
}

void solve()
{
    string s;
    cin >> s;

    int state = 1;
    string front = "", back = "";
    int q;
    cin >> q;
    while(q--) {
        int t;
        cin >> t;
        if(t == 1) {
            state = 3 - state;
        } else {
            int d;
            char c;
            cin >> d >> c;

            if(d == state) front.push_back(c);
            else back.push_back(c);
        }
    }

    if(state == 2) swap(front, back);
    reverse(front.begin(), front.end());
    if(state == 2) reverse(s.begin(), s.end());
    cout << front + s + back << '\n';

    return;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    init();
    int t = 1;
    cin >> t;
    for(int i=1; i<=t; i++){
        // cout << "Case " << i << ": ";
        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 15:54:54
Judged At
2024-09-05 15:54:54
Judged By
Score
100
Total Time
121ms
Peak Memory
8.887 MiB