/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 115ms 4.52 MiB
#4 Accepted 56ms 10.203 MiB
#5 Accepted 1ms 320.0 KiB
#6 Accepted 127ms 2.953 MiB
#7 Accepted 117ms 2.543 MiB
#8 Accepted 24ms 1.215 MiB
#9 Accepted 76ms 10.672 MiB
#10 Accepted 102ms 10.48 MiB
#11 Accepted 33ms 4.82 MiB
#12 Accepted 62ms 10.184 MiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+10,MOD=1000000007;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
     string s;
     cin>>s;
     deque<char>dp;
     for(char c:s)dp.push_back(c);
     int q;
     cin>>q;
     int cnt=0;
     while(q--){
        int type;
        cin>>type;
        type--;
        if(!type)cnt++;
        else{
            int p;
            char ch;
            cin>>p>>ch;
            if(p==1){
                if(cnt&1)dp.push_back(ch);
                else dp.push_front(ch);
            }
            else{
                if(cnt&1)dp.push_front(ch);
                else dp.push_back(ch);
            }
        }

     }
     string p="";
     cnt%=2;
     while(!dp.empty())p+=(dp.back()),dp.pop_back();
     if(!cnt)reverse(p.begin(),p.end());
     cout<<p<<"\n";
}




    
   
   return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-18 20:59:15
Judged At
2024-08-18 20:59:15
Judged By
Score
100
Total Time
127ms
Peak Memory
10.672 MiB