Accepted
Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
void solve()
{
string s; cin >> s;
deque<char>dq;
for (int i = 0; i < s.size(); i++) {
dq.push_back(s[i]);
}
int q; cin >> q;
bool shuja = true;
while(q--) {
int a; cin >> a;
if (a == 1) {
shuja ^= true;
}
else if (a == 2){
int d; cin >> d;
char c; cin >> c;
if (shuja) {
if (d == 1) {
dq.push_front(c);
}
else if (d == 2){
dq.push_back(c);
}
}
else if (!shuja) {
if (d == 1) {
dq.push_back(c);
}
else if (d == 2) {
dq.push_front(c);
}
}
}
}
if (!shuja) {
reverse(dq.begin(),dq.end());
}
for (auto x : dq) {
cout << x;
}
cout << endl;
}
int32_t 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
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-09-06 06:30:51
- Judged At
- 2024-11-11 02:56:51
- Judged By
- Score
- 100
- Total Time
- 145ms
- Peak Memory
- 8.152 MiB