/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 484.0 KiB
#2 Accepted 2ms 540.0 KiB
#3 Accepted 117ms 4.43 MiB
#4 Accepted 47ms 10.281 MiB
#5 Accepted 1ms 540.0 KiB
#6 Accepted 128ms 3.023 MiB
#7 Accepted 124ms 2.488 MiB
#8 Accepted 24ms 1.223 MiB
#9 Accepted 68ms 10.672 MiB
#10 Accepted 95ms 10.449 MiB
#11 Accepted 33ms 5.133 MiB
#12 Accepted 54ms 10.074 MiB

Code

// PIPRA ||  HABIB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int        long long int
#define pb         push_back
#define all(x)     x.begin(),x.end()
#define allr(x)    x.rbegin(),x.rend()
#define ii         pair<int,int>
#define endl       "\n"

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

    deque<char> dq;
    for(auto ch: s) {
        dq.push_back(ch);
    }

    int q;  cin >> q;
    int count = 0;

    while(q--){
        int type;
        cin >> type;
        count += (type == 1);

        if(type == 2){
            int d;  
            char ch;
            cin >> d >> ch;
            d--;

            if(count & 1)   d ^= 1;
            if(d == 0){
                dq.push_front(ch);
            }
            else{
                dq.push_back(ch);
            }
        }
    }
    
    string res = "";
    for(auto e: dq) res += e;

    if(count & 1){
        reverse(all(res));
    }

    cout << res << endl;
}

int32_t main(){
    // HABIB
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); cout.tie(NULL);

    int t;    cin>>t;
    while(t--) {
        pipra();
    }
    return 0 ;
}

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-14 13:56:29
Judged At
2024-10-14 13:56:29
Judged By
Score
100
Total Time
128ms
Peak Memory
10.672 MiB