/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 2ms 544.0 KiB
#3 Accepted 199ms 2.379 MiB
#4 Accepted 120ms 7.074 MiB
#5 Accepted 2ms 544.0 KiB
#6 Accepted 197ms 2.266 MiB
#7 Accepted 122ms 2.199 MiB
#8 Accepted 25ms 1.113 MiB
#9 Accepted 86ms 7.73 MiB
#10 Accepted 108ms 7.793 MiB
#11 Accepted 35ms 2.633 MiB
#12 Accepted 69ms 7.34 MiB

Code

#include <bits/stdc++.h>
#define ll long long
#define endll '\n';
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

const int mod = 1e9 + 7, N = 1e6;

void solve()
{
   string s;
   cin >> s;
   int q;
   cin >> q;
   vector<char> pichone, samne;
   int e = 1;
   while (q--)
   {
      int op;
      cin >> op;
      if (op == 1)
      {
         e++;
      }
      else
      {
         int dir;
         char ch;
         cin >> dir >> ch;

         if (e % 2)
         {
            if (dir == 1)
            {
               samne.pb(ch);
            }
            else
               pichone.pb(ch);
         }
         else
         {
            if (dir == 1)
            {
               pichone.pb(ch);
            }
            else
               samne.pb(ch);
         }
      }
   }



   if(e % 2) {
      reverse(all(samne));
      for(auto i : samne) cout << i;
      for(auto i : s) cout << i;
      for(auto i : pichone) cout << i;
   } 
   else {

reverse(all(pichone));
      for(auto i : pichone) cout << i;
      reverse(all(s));
      for(auto i : s) cout << i;
      for(auto i : samne) cout << i;

   }

   cout << endll;
}

int32_t main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   int t = 1;
   cin >> t;
   while (t--)
   {
      solve();
   }
   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:51:32
Judged At
2024-09-05 15:51:32
Judged By
Score
100
Total Time
199ms
Peak Memory
7.793 MiB