/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Accepted 638ms 2.516 MiB
#4 Accepted 204ms 8.945 MiB
#5 Accepted 2ms 328.0 KiB
#6 Accepted 667ms 2.598 MiB
#7 Accepted 600ms 2.395 MiB
#8 Accepted 117ms 1.332 MiB
#9 Accepted 300ms 9.246 MiB
#10 Accepted 435ms 7.973 MiB
#11 Accepted 146ms 4.664 MiB
#12 Accepted 219ms 9.109 MiB

Code

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

int main(){
  int t;
  cin >> t;
  while (t--){
    int q, ok = 0;
    string s, s1, s2;
    cin >> s >> q;
    for (int i = 0; i < q; i++){
      int a, d;
      char c;
      cin >> a;
      if (a == 1){
        ok ^= 1;
      } else {
        cin >> d >> c;
        if (d == 1){
          if (ok) s2 += c;
          else s1 += c;
        } else {
          if (ok) s1 += c;
          else s2 += c;
        }
      }
    }
    if (ok){
      reverse(s.begin(), s.end());
      reverse(s2.begin(), s2.end());
      s = s2 + s + s1;
    } else {
      reverse(s1.begin(), s1.end());
      s = s1 + s + s2;
    }
    cout << s << endl;
  }
}

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:00:15
Judged At
2024-10-03 13:09:31
Judged By
Score
100
Total Time
667ms
Peak Memory
9.246 MiB