/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 356.0 KiB
#3 Accepted 113ms 2.387 MiB
#4 Accepted 19ms 7.234 MiB
#5 Accepted 2ms 540.0 KiB
#6 Accepted 122ms 2.133 MiB
#7 Accepted 118ms 2.109 MiB
#8 Accepted 23ms 1.105 MiB
#9 Accepted 38ms 7.785 MiB
#10 Accepted 65ms 7.75 MiB
#11 Accepted 24ms 2.719 MiB
#12 Accepted 23ms 7.344 MiB

Code

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
#define sz(x) (ll)(x).size()
#define rd ({ll x; cin >> x; x; })
#define dbg(x) cerr << "[" #x "]  " << (x) << "\n\n"
// #define errv(x) {cerr << "["#x"]  ["; for (const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
// #define errvn(x, n) {cerr << "["#x"]  ["; for (auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
// #define cerr if(0)cerr
#define xx first
#define yy second
mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
/*_________________________________________________________________________________________________________________________*/

void Solve()
{
    string a;
    cin >> a;
    string lr[2];
    ll q;
    cin >> q;
    bool which = 0;
    while (q--) {
        ll qr;
        cin >> qr;
        if (qr == 1) {
            which ^= 1;
            continue;
        }
        ll d;
        cin >> d;
        char c;
        cin >> c;
        if (d == 2) {
            ll end = 1;
            if (which) {
                end = 0;
            }
            lr[end] += c;
        } else {
            ll end = 0;
            if (which) {
                end = 1;
            }
            lr[end] += c;
        }
    }
    if (!which) {
        reverse(lr[0].begin(), lr[0].end());
        cout << lr[0] << a << lr[1] << "\n";
    } else {
        reverse(lr[1].begin(), lr[1].end());
        reverse(a.begin(), a.end());
        cout << lr[1] << a << lr[0] << "\n";
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": "; // cout << "Case " << i << ": ";
        Solve();
    }
    return 0;
}
// Coded by Tahsin Arafat (@TahsinArafat)

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:04:06
Judged At
2024-09-05 16:04:06
Judged By
Score
100
Total Time
122ms
Peak Memory
7.785 MiB