/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 376.0 KiB
#3 Accepted 375ms 3.246 MiB
#4 Accepted 209ms 8.227 MiB
#5 Accepted 2ms 532.0 KiB
#6 Accepted 410ms 2.336 MiB
#7 Accepted 379ms 1.957 MiB
#8 Accepted 70ms 1.074 MiB
#9 Accepted 264ms 8.336 MiB
#10 Accepted 346ms 8.035 MiB
#11 Accepted 106ms 3.703 MiB
#12 Accepted 226ms 8.207 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
       string s;
        cin>>s;
    deque<char>dq;
        for(int i=0;i<s.size();i++)
            dq.push_back(s[i]);
        
        ll q;
        cin>>q;
        ll c=0;
        while(q--)
        {
            ll x;
            cin>>x;
            if(x==1)
            {
                c++;
                
                
            }
            else
            {
                ll y;
                cin>>y;
                char ch;
                cin>>ch;
                if(y==1)
                {
                    if(c%2==0)
                        dq.push_front(ch);
                    else
                        dq.push_back(ch);
                }
                else
                {
                    if(c%2==0)
                        dq.push_back(ch);
                    else
                        dq.push_front(ch);
            
                }
            }
        }
        if(c%2==0){
            for(auto it:dq)
                cout<<it;
        cout<<endl;}
        else
        {
            for(int i=dq.size()-1;i>=0;i--)
                cout<<dq[i];
            cout<<endl;
        }
    }
}

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 20:19:03
Judged At
2024-11-11 02:57:05
Judged By
Score
100
Total Time
410ms
Peak Memory
8.336 MiB