/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 119ms 2.371 MiB
#4 Accepted 22ms 7.098 MiB
#5 Accepted 1ms 324.0 KiB
#6 Accepted 140ms 1.996 MiB
#7 Accepted 132ms 1.793 MiB
#8 Accepted 26ms 776.0 KiB
#9 Accepted 46ms 7.746 MiB
#10 Accepted 70ms 7.707 MiB
#11 Accepted 29ms 2.633 MiB
#12 Accepted 27ms 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-11-11 03:01:32
Judged By
Score
100
Total Time
140ms
Peak Memory
7.746 MiB