/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 396.0 KiB
#3 Accepted 359ms 2.496 MiB
#4 Accepted 129ms 7.98 MiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 398ms 2.332 MiB
#7 Accepted 364ms 2.027 MiB
#8 Accepted 70ms 1008.0 KiB
#9 Accepted 189ms 8.242 MiB
#10 Accepted 281ms 8.133 MiB
#11 Accepted 91ms 2.754 MiB
#12 Accepted 144ms 8.219 MiB

Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
       string s;
       cin>>s;
       int q;
       cin>>q;

       long long rev=0;
       string left;
       string right;
       for(int i=0;i<q;i++)
       {
           long long input;
           cin>>input;

           long long hey;
           char ch;
           if(input==2)
           {
               cin>>hey;
               cin>>ch;

           }

           if(input==1)
           {
               rev++;

           }
           else if(input==2)
           {
               if(rev%2==0)
               {
                   if(hey==1)
                   left.push_back(ch);
                   else
                    right.push_back(ch);
               }
               else
               {
                    if(hey==2)
                   left.push_back(ch);
                   else
                    right.push_back(ch);

               }
           }
       }

       if(rev%2==0)
       {
           reverse(left.begin(),left.end());

           cout<<left;
           cout<<s;
           cout<<right<<endl;
       }
       else
       {
           reverse(right.begin(),right.end());

           cout<<right;

           reverse(s.begin(),s.end());
           cout<<s;
           cout<<left<<endl;

       }
    }
}

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Contest
Brain Booster #5
Language
C++11 (G++ 13.2.0)
Submit At
2024-09-05 16:20:03
Judged At
2024-11-11 03:00:54
Judged By
Score
100
Total Time
398ms
Peak Memory
8.242 MiB