/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Accepted 743ms 2.527 MiB
#4 Accepted 225ms 8.918 MiB
#5 Accepted 2ms 536.0 KiB
#6 Accepted 699ms 2.59 MiB
#7 Accepted 629ms 2.594 MiB
#8 Accepted 124ms 1.328 MiB
#9 Accepted 323ms 9.086 MiB
#10 Accepted 486ms 7.938 MiB
#11 Accepted 157ms 4.609 MiB
#12 Accepted 253ms 8.973 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-11-11 03:02:04
Judged By
Score
100
Total Time
743ms
Peak Memory
9.086 MiB