/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 2ms 340.0 KiB
#3 Accepted 129ms 3.398 MiB
#4 Accepted 70ms 7.184 MiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 139ms 2.27 MiB
#7 Accepted 134ms 2.027 MiB
#8 Accepted 27ms 1.09 MiB
#9 Accepted 90ms 8.02 MiB
#10 Accepted 121ms 7.719 MiB
#11 Accepted 40ms 3.621 MiB
#12 Accepted 83ms 7.809 MiB

Code

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

namespace solve {
  namespace test_case {

    void main() {
      string s; int q, x; cin >> s >> q;
      deque<char> dq(s.begin(), s.end());
      bool f (false);
      while (q-- && cin >> x) {
        if (x == 1) {
          f = !f;
        } else {
          int d;  char c; cin >> d >> c;
          (d == 1 && !f) || (d == 2 && f) ? dq.push_front(c) : dq.push_back(c);
        }
      }
      if (f) reverse(dq.begin(), dq.end());
      for (char c : dq) cout << c;
      cout << '\n';
    }
  }

  void main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; 
    cin >> t; 
    while (t--) {
      test_case::main();
    }
  }
}

signed main() { solve::main(); }

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:44:04
Judged At
2024-11-11 03:03:00
Judged By
Score
100
Total Time
139ms
Peak Memory
8.02 MiB