/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 340.0 KiB
#3 Accepted 135ms 3.258 MiB
#4 Accepted 75ms 7.664 MiB
#5 Accepted 1ms 320.0 KiB
#6 Accepted 145ms 2.359 MiB
#7 Accepted 142ms 2.055 MiB
#8 Accepted 26ms 1.016 MiB
#9 Accepted 98ms 8.152 MiB
#10 Accepted 124ms 7.914 MiB
#11 Accepted 40ms 3.656 MiB
#12 Accepted 81ms 7.258 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-11-11 02:56:51
Judged By
Score
100
Total Time
145ms
Peak Memory
8.152 MiB