/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 336.0 KiB
#2 Accepted 2ms 328.0 KiB
#3 Accepted 612ms 2.406 MiB
#4 Accepted 188ms 8.113 MiB
#5 Accepted 2ms 328.0 KiB
#6 Accepted 664ms 2.184 MiB
#7 Accepted 633ms 2.051 MiB
#8 Accepted 121ms 1.109 MiB
#9 Accepted 311ms 8.266 MiB
#10 Accepted 445ms 8.129 MiB
#11 Accepted 167ms 2.68 MiB
#12 Accepted 259ms 8.043 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-10-03 13:09:43
Judged By
Score
100
Total Time
664ms
Peak Memory
8.266 MiB