/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 1ms 320.0 KiB
#3 Accepted 120ms 2.383 MiB
#4 Accepted 22ms 7.055 MiB
#5 Wrong Answer 1ms 320.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>*/
typedef long long ll;
#define N 200001
#define lcm(a,b) ((a*b)/__gcd(a,b))
const ll mod=1e9+7;
        ll prime[N];
        vector<int>all_primes;
        ll prime_factors[N];
        void seive()
        {
            memset(prime,0,sizeof(prime));
            prime[0]=1;prime[1]=1;
            for(ll i=2;i*i<=N-1;i++)
            {
            if(prime[i]==0)
                {
                    for(ll j=i*i;j<N;j+=i)
                    {
                        prime[j]=1;
                    }
                }
            }
            for(int i=1;i<N;i++)
            {
                if(!prime[i])
                {
                    all_primes.push_back(i);
                }
            }
        }

        void spf()
        {
            for(ll i=1;i<N;i++)
            {
                prime_factors[i]=i;
            }

            for(ll i=2;i*i<=N-1;i++)
            {
                for(ll j=i*i;j<=N-1;j+=i)
                {
                    if(prime_factors[j]==j)
                        prime_factors[j]=i;
                }
            }
        }
//code starts here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    //t=1;
    while(t--)
    {
       string s;
       cin>>s;
       vector<char>V,VV;
       int q;
       cin>>q;
       int cnt=0;
       for(int i=0;i<q;i++)
       {
           int x;
           cin>>x;
           if(x==2)
           {
               int l;
               char c;
               cin>>l>>c;
               if(l==1)
               {
                   if(cnt%2==0)
                    V.push_back(c);
                   else
                    VV.push_back(c);
               }
               else
               {
                   if(cnt%2==0)
                    VV.push_back(c);
                   else
                    V.push_back(c);
               }
           }
           else
            cnt++;
       }
        if(cnt%2)
        {
            for(auto &it : VV)
            cout<<it;

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

            for(auto &it : V)
            cout<<it;

            cout<<"\n";
            continue;
        }
        for(auto &it : V)
            cout<<it;

        cout<<s;

        for(auto &it : VV)
            cout<<it;

        cout<<"\n";
    }
}

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 16:25:38
Judged At
2024-11-11 03:00:42
Judged By
Score
20
Total Time
120ms
Peak Memory
7.055 MiB