/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 536.0 KiB
#3 Accepted 113ms 2.379 MiB
#4 Accepted 84ms 7.215 MiB
#5 Accepted 2ms 532.0 KiB
#6 Time Exceeded ≥1099ms ≥1.707 MiB
#7 Time Exceeded ≥1100ms ≥796.0 KiB
#8 Time Exceeded ≥1100ms ≥772.0 KiB
#9 Time Exceeded ≥1100ms ≥1.625 MiB
#10 Accepted 66ms 7.75 MiB
#11 Time Exceeded ≥1099ms ≥1.625 MiB
#12 Time Exceeded ≥1100ms ≥1.664 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define vv vector<long long>
#define mpp map<long long,long long>
#define ss set<long long>
#define vp vector<pair<long long, long long>>
#define MOD 1000000007
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define all_v v.begin(),v.end()
#define all_a a.begin(),a.end()
#define all_n for(int i=0;i<n;i++)
void requisite(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
}
int main() {
    requisite();
    ll t;
    cin>>t;
    while (t--){
        string s;
        cin>>s;
        ll q;
        cin>>q;
        bool rev=false;
        deque<char> beg;
        deque<char> end;
        for (int i = 0; i < q; ++i) {
            char c;
            ll a,b;
            cin>>a;
            if (a==1){
                rev=(!rev);
                reverse(beg.begin(),beg.end());
                reverse(end.begin(),end.end());
                swap(beg,end);
            }
            else{
                cin>>b>>c;
                if (b==1){
                    beg.push_front(c);
                }
                else{
                    end.push_back(c);
                }
            }
//            cout<<beg<<" "<<end<<endl;
        }
        if (rev){
           reverse(s.begin(), s.end());
            for(auto it:beg)cout<<it;
            cout<<s;
            for(auto it:end)cout<<it;
            cout<<endl;
        }
        else{
            for(auto it:beg)cout<<it;
            cout<<s;
            for(auto it:end)cout<<it;
            cout<<endl;
        }
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Language
C++17 (G++ 13.2.0)
Submit At
2024-09-05 18:46:33
Judged At
2024-09-05 18:46:33
Judged By
Score
40
Total Time
≥1100ms
Peak Memory
≥7.75 MiB