/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 120ms 3.379 MiB
#4 Accepted 29ms 8.133 MiB
#5 Accepted 2ms 324.0 KiB
#6 Time Exceeded ≥1092ms ≥1.77 MiB
#7 Accepted 663ms 2.566 MiB
#8 Accepted 100ms 1.371 MiB
#9 Accepted 126ms 8.773 MiB
#10 Accepted 75ms 7.734 MiB
#11 Accepted 101ms 3.887 MiB
#12 Accepted 53ms 8.32 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve(){
	string s;
	cin >> s;
	int q;
	cin >> q;
	bool reversed = false;
	string first= "", last = "";
	while(q--){
		int type;
		cin >> type;
		if(type == 1){
			reversed = !reversed;
		}
		else {
			int d;
			char c;
			cin >> d >> c;
			if(!reversed){
				if(d == 1){
					first = c + first;
				}
				else {
					last += c;
				}
			}
			else {
				if(d == 1){
					last += c;
				}
				else {
					first = c + first;
				}
			}

		}

	}
	//cout << first << " " << last << '\n';
	if(reversed){
		reverse(s.begin(),s.end());
		reverse(last.begin(),last.end());
		reverse(first.begin(),first.end());
		cout << last + s + first << '\n';
	}
	else {
		cout << first + s + last << '\n';
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	cin >> t;
	while(t--){
		solve();
	}
	return 0;
}
//dcbaef
//feabcd

Information

Submit By
Type
Submission
Problem
P1088 Mr. Heart's String Challenge
Contest
Brain Booster #5
Language
C++17 (G++ 13.2.0)
Submit At
2024-09-05 16:28:59
Judged At
2024-11-11 03:00:32
Judged By
Score
90
Total Time
≥1092ms
Peak Memory
≥8.773 MiB