/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 432.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 118ms 2.367 MiB
#4 Accepted 23ms 7.094 MiB
#5 Accepted 1ms 320.0 KiB
#6 Accepted 130ms 2.199 MiB
#7 Accepted 124ms 2.109 MiB
#8 Accepted 25ms 1.062 MiB
#9 Accepted 45ms 7.867 MiB
#10 Accepted 71ms 7.91 MiB
#11 Accepted 27ms 2.629 MiB
#12 Accepted 27ms 7.289 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define Raihan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*
vector<ll>v={1,2,3};
    do{

    }while(next_permutation(all(v)));
*/
/*

const int N=1e6+5;
bool f[N];
vector<int>prim;
for(int i=2;i*i<N;i++){
    if(!f[i]){
        for(int j=i*i;j<N;j=j+i){
            f[j]=true;
        }
    }
}
for(int i=2;i<N;i++){
    if(!f[i])prim.pb(i);
}*/

/*round(pow(5, 2))*/
/*
ll l=1,r=n;
    while(l<=r){
        ll mi=(l+r)/(ll)2;//upper bound
        if(a[mi]>dor)r=mi-1;
        else l=mi+1;
    }
*/
/*
memset(a,-1,sizeof a);
it works for 0,-1 and character,and faster than looping*/
/*
int ps=s[i]-'a'+1;
int ps=s[i]-'0'+1;
int ps=s[i]-'A'+1;
char ch='a'-1+i;
char ch='A'-1+i;
*/
/*set<int>st;
   st.insert(3);
   st.insert(4);
   for(auto it=st.begin(); it!=st.end(); it++)cout<<*it<<spc;
   cout<<endl;
   auto fi=st.begin();
   //s1.erase(fi);
   cout<<*fi<<endl;
   auto las=st.end();
   las--;
   cout<<*las<<endl;
   auto it=st.lower_bound(4);
   cout<<*it<<endl;
   it=st.upper_bound(4);
   cout<<*it<<endl;
   */
/*
for(auto it=st.begin(); it!=st.end(); it++)cout<<*it<<spc;
*/
/*
biyog korle ei doroner mod korbe.mod er problem e.
ll ans=fi-sc;
if(ans<0){
ans=ans+mod;
}
ll fact[N];
void ft()
{
	fact[0] = 1;
	for(ll i=1;i<N;i++)
	{
		fact[i] = i * fact[i - 1];
		fact[i] %= mod;
	}
}
ll pwr(long long p, long long q, const ll mod1)
{
	ll ans = (ll)1 % mod1;
	p %= mod1;
	if (p < 0)
		p += mod1;
	while (q)
	{
		if (q & (ll)1)
			ans = ((ans%mod1)*(p%mod1)) % mod1;
		p = ((p%mod1)*(p%mod1)) % mod1;
		q >>= (ll)1;
	}
	return ans;
}

ll ncr(ll n, ll r)
{
	if (n < r)
		return (ll)0;
	ll ans = (ll)1;
	ans *= fact[n];
	ll div = fact[r];
	div *= fact[n - r];
	div %= mod;
	ans *= pwr(div, mod - (ll)2, mod);
	ans %= mod;
	return ans;
}
    ll ck(ll ans){
    if(ans<0)ans=ans+mod;
        return ans%mod;
    }
*/
/*
vector<int>v({1,1,1,2,3,4,4});
    ll z=lower_bound(all(v),4)-v.begin();
    ll z1=upper_bound(all(v),4)-v.begin();
    cout<<z<<spc<<z1;
*/
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mod 1000000007
#define vec vector<int>
#define print1(pr) for(int i=0;i<pr.size();i++)cout<<pr[i]<<spc;cout<<endl;
#define print2(pr) for(int i=pr.size()-1;i>=0;i--)cout<<pr[i];cout<<endl;
#define pb push_back
#define test int tes ;cin>>tes;while(tes--)
#define pi 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define no cout<<"NO"<<endl
#define yes cout<<"YES"<<endl
#define pii pair<int,int>
#define pII pair<ll,ll>
#define endl '\n'
#define spc " "
#define vl it->first
#define fq it->second
/*
int t;cin>>t;loop(i,1,t) cout<<"Case "<<i<<": ",solution();
*/
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define kajj for(auto it=mp.begin();it!=mp.end();it++)
#define input ll n;cin>>n;ll a[n+1];for(int i=1;i<=n;i++)cin>>a[i];
#define lc (nd<<1)
#define rc ((nd<<1)+1)
void solution()
{
    string s,s1,s2;
    cin>>s;
    ll si=s.size();
    ll q,cnt=0;
    cin>>q;
    while(q--)
    {
        ll x;
        cin>>x;
        if(x==1)
        {
            cnt=cnt^1;
        }
        else
        {
            ll d;
            char ch;
            cin>>d>>ch;
            if(d==1&&cnt==0){
                s1+=ch;
            }
            else if(d==2&&cnt==0){
                s2+=ch;
            }
            else if(d==1&&cnt==1){
                s2+=ch;
            }
            else if(d==2&&cnt==1){
                s1+=ch;
            }
        }
    }
    if(cnt==1){
        reverse(all(s));
        reverse(all(s2));
        cout<<s2<<s<<s1<<endl;
    }
    else{
            reverse(all(s1));
         cout<<s1<<s<<s2<<endl;
    }
    /*
    1
abc
4
2 1 d
1
2 2 e
1*/
}
int main()
{
    Raihan;
    test
    solution();
}

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:36:44
Judged At
2024-10-03 13:06:54
Judged By
Score
100
Total Time
130ms
Peak Memory
7.91 MiB