/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 121ms 3.246 MiB
#4 Accepted 66ms 7.336 MiB
#5 Accepted 1ms 324.0 KiB
#6 Accepted 137ms 2.355 MiB
#7 Accepted 127ms 2.25 MiB
#8 Accepted 26ms 892.0 KiB
#9 Accepted 88ms 8.141 MiB
#10 Accepted 115ms 7.699 MiB
#11 Accepted 37ms 3.578 MiB
#12 Accepted 72ms 7.77 MiB

Code

#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using ll = long long;

int main() {
  FAST;
  
  int tc = 1, ti;
  cin >> tc;

  for (ti = 1; ti <= tc; ++ti) {
    string s;
    cin >> s;
    deque<char> d(s.begin(), s.end());

    int q, t, m, f;
    char c;
    f = 1;

    cin >> q; while (q--) {
      cin >> t;
      if (t == 1) {
        f ^= 1;
      } else {
        cin >> m >> c;
        if (f == 1) {
          if (m == 1) d.push_front(c);
            else d.push_back(c);
        } else {
          if (m == 2) d.push_front(c);
            else d.push_back(c);
        }
      }
    }

    if (f == 0) reverse(d.begin(), d.end());

    for (char x : d) cout << x;
    cout << "\n";
  }

  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 15:36:36
Judged At
2024-10-03 13:11:21
Judged By
Score
100
Total Time
137ms
Peak Memory
8.141 MiB