/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 311ms 2.418 MiB
#4 Accepted 105ms 8.027 MiB
#5 Accepted 2ms 320.0 KiB
#6 Accepted 375ms 2.344 MiB
#7 Accepted 316ms 2.117 MiB
#8 Accepted 87ms 1.09 MiB
#9 Accepted 171ms 8.125 MiB
#10 Accepted 233ms 8.023 MiB
#11 Accepted 115ms 2.723 MiB
#12 Accepted 164ms 8.145 MiB

Code

#include <bits/stdc++.h>
//#define ll long long int

using namespace std;
typedef long long int ll;
priority_queue<int, vector<int>, greater<int>> pq;
const ll md = 1e9 + 7;
const ll md1 = 998244353;
map<ll, vector<ll>> tree;
//map<ll, int> mp;
ll get(ll l,ll r,ll n){


}
void sufi() {
string s;
cin>>s;
vector<char>v1;
vector<char>v2;
int c=0;
int q;
cin>>q;
while(q--){
	int a;
	cin>>a;
	if(a==1)c=abs(c-1);
	else{
		int d;
		cin>>d;
		char ch;
		cin>>ch;
		if(d==1){
			if(c==0)v1.push_back(ch);
			else v2.push_back(ch);
		}
		else{
			if(c==0)v2.push_back(ch);
			else v1.push_back(ch);
		}
	}
}
//cout<<v1.size()<<" "<<v2.size()<<endl;
if(c==0){
	if(v1.size()){
		auto it=v1.end();
		it--;
		while(1){
			cout<<*it;
			if(it==v1.begin())break;
			it--;
		}
	}
	cout<<s;
	if(v2.size()){
		for(auto it:v2)cout<<it;
	}
	cout<<endl;
}
else{
	if(v2.size()){
		auto it=v2.end();
		it--;
		while(1){
			cout<<*it;
			if(it==v2.begin())break;
			it--;
		}
	}
	auto it1=s.end();
	it1--;
	while(1){
			cout<<*it1;
			if(it1==s.begin())break;
			it1--;
		}

	if(v1.size()){
		for(auto it:v1)cout<<it;
	}
	cout<<endl;
}
}
int main() {
    int t;
cin>>t;
    while (t--) {
        sufi();
       tree.clear();
        //mp.clear();
    }
    return 0;
}

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 15:56:36
Judged At
2024-09-05 15:56:36
Judged By
Score
100
Total Time
375ms
Peak Memory
8.145 MiB