/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 2ms 324.0 KiB
#3 Accepted 343ms 3.238 MiB
#4 Accepted 175ms 8.102 MiB
#5 Accepted 2ms 536.0 KiB
#6 Accepted 389ms 2.336 MiB
#7 Accepted 359ms 2.027 MiB
#8 Accepted 68ms 868.0 KiB
#9 Accepted 243ms 8.508 MiB
#10 Accepted 322ms 8.125 MiB
#11 Accepted 95ms 3.598 MiB
#12 Accepted 192ms 8.145 MiB

Code

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

void solve() {
    string str;
    cin>>str;
    int q;
    cin>>q;
    deque<char> deq(str.begin(),str.end());

    bool rf=false;

    while(q--){
        int type;
        cin>>type;
        if(type==1){
            rf=!rf;
        }
        else if(type==2){
            int d;cin>>d;
            char c;cin>>c;
            if(rf){
                if(d==1){
                    deq.push_back(c);
                }
                else{
                    deq.push_front(c);
                }
            }
            else{
                if(d==1){
                    deq.push_front(c);
                }
                else{
                    deq.push_back(c);
                }
            }
        }
    }
    if(rf)reverse(deq.begin(),deq.end());
    for(auto ch: deq){
        cout<<ch;
    }
    cout<<endl;

}

int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
return 0;
}

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Contest
Brain Booster #5
Language
C++17 (G++ 13.2.0)
Submit At
2024-09-05 16:30:22
Judged At
2024-10-03 13:07:22
Judged By
Score
100
Total Time
389ms
Peak Memory
8.508 MiB