/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 524.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Time Exceeded ≥1081ms ≥1.469 MiB
#4 Time Exceeded ≥1088ms ≥1.473 MiB
#5 Accepted 1ms 324.0 KiB
#6 Time Exceeded ≥1086ms ≥1.574 MiB
#7 Time Exceeded ≥1092ms ≥780.0 KiB
#8 Time Exceeded ≥1079ms ≥776.0 KiB
#9 Time Exceeded ≥1092ms ≥1.465 MiB
#10 Time Exceeded ≥1086ms ≥1.465 MiB
#11 Time Exceeded ≥1080ms ≥1.547 MiB
#12 Time Exceeded ≥1085ms ≥1.469 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;
                reverse(all(s));
                reverse(all(pre));
                reverse(all(suf));
            }
            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 == 2) pre.push_back(c);
                    else suf.push_front(c);
                }
            }
        }
        if(rev) {
            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 15:56:50
Judged At
2024-10-03 13:09:40
Judged By
Score
15
Total Time
≥1092ms
Peak Memory
≥1.574 MiB