/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 115ms 3.262 MiB
#4 Accepted 64ms 7.711 MiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 126ms 2.27 MiB
#7 Accepted 119ms 2.031 MiB
#8 Accepted 54ms 1.09 MiB
#9 Accepted 85ms 8.164 MiB
#10 Accepted 110ms 7.883 MiB
#11 Accepted 37ms 3.672 MiB
#12 Accepted 72ms 7.297 MiB

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'

void solve()
{   
    string s; cin >> s;
    deque<char>dq;
    for (int i = 0; i < s.size(); i++) {
        dq.push_back(s[i]);
    }
    int q; cin >> q;
    bool shuja = true;
    while(q--) {
        int a; cin >> a;
        if (a == 1) {
            shuja ^= true;
        }
        else if (a == 2){
            int d; cin >> d;
            char c; cin >> c;
            if (shuja) {
                if (d == 1) {
                    dq.push_front(c);
                }
                else if (d == 2){
                    dq.push_back(c);
                }
            }
            else if (!shuja) {
                if (d == 1) {
                    dq.push_back(c);
                }
                else if (d == 2) {
                    dq.push_front(c);
                }
            }
        }
    }

    if (!shuja) {
        reverse(dq.begin(),dq.end());
    }
    for (auto x : dq) {
        cout << x;
    }
    cout << endl;

}

int32_t main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1; cin >> t;
    while(t--) solve();
    return 0;
} 

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-06 06:30:51
Judged At
2024-09-06 06:30:51
Judged By
Score
100
Total Time
126ms
Peak Memory
8.164 MiB