/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 324.0 KiB
#2 Accepted 2ms 320.0 KiB
#3 Accepted 120ms 2.371 MiB
#4 Time Exceeded ≥1085ms ≥4.355 MiB
#5 Accepted 2ms 320.0 KiB
#6 Time Exceeded ≥1095ms ≥1.074 MiB
#7 Time Exceeded ≥1091ms ≥1.062 MiB
#8 Time Exceeded ≥1090ms ≥1.082 MiB
#9 Time Exceeded ≥1088ms ≥3.43 MiB
#10 Accepted 66ms 7.699 MiB
#11 Time Exceeded ≥1074ms ≥3.438 MiB
#12 Time Exceeded ≥1027ms ≥3.43 MiB

Code

#include <bits/stdc++.h>
 
using namespace std;
 
// Macros
#define REP(i, j, n) for(int i = j; i < n; i++)
#define trav(i, a) for(auto i: a)
#define all(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define GCD __gcd
 
// Type Names
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

// Global Variables
const int MOD = 1e9 + 7;

// custom hash
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// print vector X)
template <typename T>
void print_vector(vector<T> a){
    int n = a.size();
    for (int i = 0; i < n; i++){
        cout << a[i] << (i == n - 1 ? "\n" : " ");
    }
}

template <typename T>
void print_2d_vector(vector<vector<T>> a){
    int row = a.size();
    int col = a[0].size();
    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            cout << a[i][j] << " ";
        }
        cout << "\n";
    }
}

template <typename T>
void print_stack(stack<T> st){
    while (!st.empty()){
        cout << st.top() << " ";
        st.pop();
    }
    cout << "\n";
}

template <typename T>
void print_set(set<T> s){
    for (auto itr = s.begin(); itr != s.end(); itr++){
        cout << *itr << " ";
    }
    cout << "\n";
}

template <typename T>
void print_set(multiset<T> s){
    for (auto itr = s.begin(); itr != s.end(); itr++){
        cout << *itr << " ";
    }
    cout << "\n";
}

string int_to_bin(ll n){
    string ans = "";
    while (n) {
        ans = to_string(n % 2) + ans;
        n /= 2;
    }
    return ans;
}

ull bin_to_int(string s){
    bitset<20> bin(s);
    return bin.to_ulong();
}

ll find_next(ll l, ll n){
    if ((l - 1) % n == 0) return l - 1;
    else return (((l - 1) / n) * n) + n;
}

ll find_prev(ll r, ll n){
    return (r / n) * n;
}

bool change_state(bool cond){
    if (cond) return false;
    else return true;
}

void solve()
{   
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = false;
    while(q--){
        int type;
        cin >> type;
        if (type == 1) rev = change_state(rev);
        else {
            int place;
            char c;
            cin >> place >> c;
            if (!rev){
                if (place == 1) s = c + s;
                else s = s + c;
            }
            else{
                if (place == 1) s = s + c;
                else s = c + s;
            }
        }
    }
    if (rev) reverse(all(s));
    cout << s << "\n";
}

 
int main()
{
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("breedflip.in", "r", stdin);
    // freopen("breedflip.out", "w", stdout);
    int t;
    cin >> t;
    for(int i = 1; i <= t; i++)
    solve();
    return 0;
}

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 16:37:22
Judged At
2024-10-03 13:06:45
Judged By
Score
30
Total Time
≥1095ms
Peak Memory
≥7.699 MiB