/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Wrong Answer 2ms 512.0 KiB
#3 Wrong Answer 595ms 3.359 MiB
#4 Wrong Answer 314ms 8.223 MiB
#5 Wrong Answer 2ms 540.0 KiB
#6 Wrong Answer 682ms 2.328 MiB
#7 Wrong Answer 644ms 1.961 MiB
#8 Wrong Answer 119ms 1012.0 KiB
#9 Wrong Answer 429ms 9.289 MiB
#10 Wrong Answer 598ms 8.227 MiB
#11 Wrong Answer 179ms 3.906 MiB
#12 Wrong Answer 353ms 8.441 MiB

Code

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

void solve() 
{
    string s; 
    cin>>s;
    int q; 
    cin>>q;

    deque<char>f; 
    deque<char>b; 
    bool r=false; 

    for (int i=0; i<q; ++i){
        int ty;
        cin>>ty;
        if(ty==1){
            r=!r; 
        } 
        else if(ty==2){
            int d;
            char c;
            cin>>d>>c;
            if(d==1){
                if(!r){
                    f.push_front(c); 
                } 
                else{
                    b.push_back(c);
                }
            } 
            else if(d==2){
                if(!r){
                    b.push_back(c);
                } 
                else{
                    f.push_front(c);
                }
            }
        }
    }
    if(!r){
        for(char ch:s){
            b.push_front(ch); 
        }
    } 
    else{
        for(char ch:s){
            f.push_back(ch);
        }
    }

    if(r){
        
        for(auto it=f.rbegin(); it!=f.rend(); ++it){
            cout << *it;
        }
        for(char ch:b){
            cout<<ch;
        }
    } 
    else{
        for(char ch:b){
            cout<<ch;
        }
        for(char ch:f){
            cout<<ch;
        }
    }
    cout<<endl;
}

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

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 17:35:59
Judged At
2024-10-03 13:03:05
Judged By
Score
5
Total Time
682ms
Peak Memory
9.289 MiB