/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Accepted 2ms 540.0 KiB
#3 Accepted 186ms 2.375 MiB
#4 Accepted 30ms 7.301 MiB
#5 Accepted 2ms 328.0 KiB
#6 Accepted 225ms 2.195 MiB
#7 Accepted 220ms 1.801 MiB
#8 Accepted 41ms 796.0 KiB
#9 Accepted 68ms 7.801 MiB
#10 Accepted 111ms 7.719 MiB
#11 Accepted 46ms 2.715 MiB
#12 Accepted 41ms 7.301 MiB

Code

/**
 *  written by Binoy Barman .
**/

#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifdef LOCAL
#include "unravel.hpp"
#else
#define dbg(...) 42
#endif
#define int long long

int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    Too_Many_Jobs {
        string s;
        cin >> s;
        deque<char> pre, suf;
        int q;
        cin >> q;
        bool rev = false;
        while(q--) {
            int t;
            cin >> t;
            if(t == 1) {
                rev = rev ^ 1;
            }
            else {
                int d;
                char c;
                cin >> d >> c;
                if(!rev) {
                    if(d == 1) pre.push_front(c);
                    else suf.push_back(c);
                }
                else {
                    if(d == 1) suf.push_back(c);
                    else pre.push_front(c);
                }
            }
        }
        if(rev) {
            reverse(all(s));
            reverse(all(pre));
            reverse(all(suf));
            for(auto c : suf) cout << c;
            cout << s;
            for(auto c : pre) cout << c;
        }
        else {
            for(auto c : pre) cout << c;
            cout << s;
            for(auto c : suf) cout << c;
        }
        cout << nl;
    }

    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 16:08:59
Judged At
2024-10-03 13:08:48
Judged By
Score
100
Total Time
225ms
Peak Memory
7.801 MiB