/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Accepted 216ms 2.371 MiB
#4 Accepted 135ms 7.09 MiB
#5 Accepted 2ms 360.0 KiB
#6 Time Exceeded ≥1013ms ≥1.66 MiB
#7 Time Exceeded ≥1040ms ≥776.0 KiB

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-11-11 02:57:27
Judged By
Score
30
Total Time
≥1040ms
Peak Memory
≥7.09 MiB