/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 359ms 2.367 MiB
#4 Accepted 130ms 7.984 MiB
#5 Accepted 2ms 532.0 KiB
#6 Accepted 404ms 2.359 MiB
#7 Accepted 384ms 2.137 MiB
#8 Accepted 72ms 1.078 MiB
#9 Accepted 210ms 8.098 MiB
#10 Accepted 280ms 7.949 MiB
#11 Accepted 105ms 2.613 MiB
#12 Accepted 176ms 7.984 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-11-11 03:02:16
Judged By
Score
100
Total Time
404ms
Peak Memory
8.098 MiB