/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 492.0 KiB
#3 Accepted 110ms 2.422 MiB
#4 Accepted 19ms 7.281 MiB
#5 Accepted 1ms 772.0 KiB
#6 Accepted 132ms 2.137 MiB
#7 Accepted 125ms 2.008 MiB
#8 Accepted 24ms 780.0 KiB
#9 Accepted 42ms 7.762 MiB
#10 Accepted 66ms 7.883 MiB
#11 Accepted 26ms 2.633 MiB
#12 Accepted 24ms 7.297 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-09-05 16:08:59
Judged By
Score
100
Total Time
132ms
Peak Memory
7.883 MiB