/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 2ms 544.0 KiB
#3 Accepted 113ms 2.383 MiB
#4 Time Exceeded ≥1100ms ≥2.465 MiB

Code

// PIPRA ||  HABIB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int        long long int
#define pb         push_back
#define all(x)     x.begin(),x.end()
#define allr(x)    x.rbegin(),x.rend()
#define ii         pair<int,int>
#define endl       "\n"

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}
using orderedTree = tree<int, null_type, less<int>, 
rb_tree_tag, tree_order_statistics_node_update>;

void pipra(){
    string s;
    cin >> s;

    int q;  cin >> q;
    int count = 0;

    while(q--){
        int type;
        cin >> type;
        count += (type == 1);

        if(type == 2){
            int t;  
            char ch;
            cin >> t >> ch;

            if(count & 1){
                reverse(all(s));
            }

            if(t == 1){
                string x = "";
                x += ch;
                // cout << x << endl;
                x += s;
                s = x;
            }
            else{
                s += ch;
            }
        }
    }

    cout << s << endl;
}

int32_t main(){
    // HABIB
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); cout.tie(NULL);

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

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-14 13:11:54
Judged At
2024-10-14 13:11:54
Judged By
Score
10
Total Time
≥1100ms
Peak Memory
≥2.465 MiB