/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 2ms 484.0 KiB
#3 Accepted 213ms 3.406 MiB
#4 Accepted 117ms 7.098 MiB
#5 Accepted 2ms 328.0 KiB
#6 Accepted 238ms 2.383 MiB
#7 Accepted 225ms 2.234 MiB
#8 Accepted 44ms 960.0 KiB
#9 Accepted 155ms 8.223 MiB
#10 Accepted 199ms 7.902 MiB
#11 Accepted 63ms 3.652 MiB
#12 Accepted 111ms 7.898 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-10-03 13:10:36
Judged By
Score
100
Total Time
238ms
Peak Memory
8.223 MiB