/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 2ms 532.0 KiB
#3 Wrong Answer 341ms 3.238 MiB
#4 Wrong Answer 174ms 8.211 MiB
#5 Wrong Answer 1ms 532.0 KiB
#6 Wrong Answer 374ms 2.215 MiB
#7 Wrong Answer 341ms 1.953 MiB
#8 Wrong Answer 67ms 1016.0 KiB
#9 Wrong Answer 246ms 8.367 MiB
#10 Wrong Answer 321ms 8.004 MiB
#11 Wrong Answer 98ms 3.629 MiB
#12 Wrong Answer 198ms 8.27 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=true;
        }
        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++20 (G++ 13.2.0)
Submit At
2024-09-05 16:29:20
Judged At
2024-10-03 13:07:24
Judged By
Score
5
Total Time
374ms
Peak Memory
8.367 MiB