/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 556.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 120ms 2.418 MiB
#4 Accepted 21ms 7.254 MiB
#5 Accepted 1ms 532.0 KiB
#6 Time Exceeded ≥1087ms ≥1.605 MiB
#7 Accepted 669ms 2.473 MiB
#8 Accepted 101ms 1.227 MiB
#9 Accepted 114ms 8.0 MiB
#10 Accepted 72ms 7.73 MiB
#11 Accepted 100ms 2.957 MiB
#12 Accepted 43ms 7.832 MiB

Code

#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;

#ifdef velox
#include "debug.h"
#else
#define debug(x...)
#endif

#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define set_bits(x) __builtin_popcountll(x)
#define fst_zero(x) 63-__builtin_ctzll(x)
#define lst_zero(x) __builtin_ctzll(x)
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) ((x/gcd(x,y))*y)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define ll long long
#define pb push_back
#define endl '\n'
#define fx(x) fixed<<setprecision(x)
template <typename T> using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll MOD = 1e9+7;

void error_txt(){
    #ifdef velox
    freopen("error.txt","w",stderr);
    #endif
}



void solve(){
    string s; cin >> s;
    ll q; cin >> q;
    bool revv=false;
    vector<char> back;
    ll in=0;
    string front="";
    while(q--){
        ll op; cin >> op;
        if(op==1) {
            if(revv) revv=false;
            else revv=true;
        }
        else{
            ll x; cin >> x;
            char c; cin >> c;
            if(x==1){
                if(revv){
                    // s+=c;
                    back.pb(c);
                }
                else{
                    // s=c+s;
                    front=c+front;
                }
            }
            else{
                if(revv) {
                    // s=c+s;
                    front=c+front;
                }
                else {
                    // s+=c;
                    back.pb(c);
                }
            }
        }

        debug(s);
    }

    s=front+s;
    for(int x=0; x<back.size(); x++) s+=back[x];
    if(revv) rev(s);
    cout << s << endl;
}

int main(){
    // error_txt();
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll t=1;
    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 17:09:26
Judged At
2024-11-11 02:58:50
Judged By
Score
90
Total Time
≥1087ms
Peak Memory
≥8.0 MiB