/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 1ms 320.0 KiB
#3 Accepted 115ms 3.383 MiB
#4 Accepted 27ms 8.121 MiB
#5 Wrong Answer 1ms 320.0 KiB
#6 Wrong Answer 144ms 2.719 MiB
#7 Wrong Answer 130ms 2.594 MiB
#8 Wrong Answer 26ms 1.363 MiB
#9 Accepted 52ms 8.914 MiB
#10 Accepted 70ms 7.738 MiB
#11 Accepted 31ms 3.902 MiB
#12 Wrong Answer 36ms 8.305 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;
				}
				else {
					last += c;
				}
			}
			else {
				if(d == 1){
					last += c;
				}
				else {
					first += c;
				}
			}

		}

	}
	if(reversed){
		reverse(s.begin(),s.end());
		reverse(last.begin(),last.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;
}

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:11:15
Judged At
2024-10-03 13:08:42
Judged By
Score
50
Total Time
144ms
Peak Memory
8.914 MiB