/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Accepted 2ms 364.0 KiB
#3 Accepted 136ms 3.254 MiB
#4 Accepted 69ms 7.23 MiB
#5 Accepted 1ms 324.0 KiB
#6 Accepted 149ms 2.336 MiB
#7 Accepted 139ms 2.242 MiB
#8 Accepted 27ms 1.012 MiB
#9 Accepted 93ms 8.199 MiB
#10 Accepted 124ms 7.789 MiB
#11 Accepted 39ms 3.52 MiB
#12 Accepted 78ms 7.746 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-11-11 03:03:39
Judged By
Score
100
Total Time
149ms
Peak Memory
8.199 MiB