/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Accepted 222ms 3.25 MiB
#4 Accepted 111ms 7.137 MiB
#5 Accepted 2ms 332.0 KiB
#6 Accepted 245ms 2.305 MiB
#7 Accepted 231ms 2.051 MiB
#8 Accepted 44ms 1.078 MiB
#9 Accepted 156ms 8.066 MiB
#10 Accepted 204ms 7.746 MiB
#11 Accepted 64ms 3.57 MiB
#12 Accepted 128ms 7.781 MiB

Code

#include <bits/stdc++.h>

using namespace std;
using i64 = long long;

void solve() {
    string s; cin >> s;
    deque<char> d (s.begin(), s.end());
    int r = 0;
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        int q; cin >> q;
        if (q == 1) r ^= 1;
        else {
            int x; cin >> x; x %= 2;
            char c; cin >> c;
            if (x ^ r) d.push_front(c);
            else d.push_back(c);
        }
    }
    if (r) reverse(d.begin(), d.end());
    for (int i = 0; i < d.size(); ++i) {
        cout << d[i];
    }
    cout << '\n';
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    i64 T; cin >> T;
    while(T--) solve();
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 17:36:01
Judged At
2024-11-11 02:45:55
Judged By
Score
100
Total Time
245ms
Peak Memory
8.066 MiB