Compile Error
foo.cc: In function 'void solve()': foo.cc:28:13: error: 'reversed' was not declared in this scope 28 | reversed= !reversed; | ^~~~~~~~ foo.cc:36:21: error: 'reversed' was not declared in this scope 36 | if (reversed) { | ^~~~~~~~ foo.cc:43:21: error: 'reversed' was not declared in this scope 43 | if (reversed) { | ^~~~~~~~ foo.cc:51:9: error: 'reversed' was not declared in this scope 51 | if (reversed) { | ^~~~~~~~
Code
/*
* @author:- SYEDA SADIATUL JANNAT TUSHI
* date & time :2024-09-05 20:55:29
* BANGLADESH , SYLHET.
*/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ll long long
#define vi vector<ll>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve() {
string s;
int q;
cin >> s >> q;
bool reversed_flag = false;
while (q--) {
int a;
cin >> a;
if (a == 1) {
reversed= !reversed;
}
else {
int d;
char c;
cin >> d >> c;
if (d == 1) {
if (reversed) {
s.push_back(c);
} else {
s.insert(s.begin(), c);
}
}
else {
if (reversed) {
s.insert(s.begin(), c);
} else {
s.push_back(c);
}
}
}
}
if (reversed) {
reverse(s.begin(), s.end());
}
cout << s << endl;
}
int main() {
fast;
ll T;
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 17:37:51
- Judged At
- 2024-10-03 13:03:01
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes