Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_CRT_SECURE_NO_WARNINGS
- #include <string>
- #include <vector>
- #include <iostream>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <math.h>
- #include <deque>
- #include <functional>
- #define forn(i, n) for (int i = 0; i < int(n); i++)
- #define fore(i, s, n) for (int i = int(s); i < int(n); i++)
- #define all(a) (a).begin(), (a).end()
- #define sz(a) a.size()
- #define ft first
- #define sc second
- #define mp make_pair
- #define pb push_back
- #define ll long long
- using namespace std;
- deque<char> f, e;
- int main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int z;
- cin >> z;
- forn(z1, z){
- string s;
- cin >> s;
- int n = s.size();
- forn(i, n)
- if (s[i] == '<' && f.size() > 0){
- e.push_front(f.back());
- f.pop_back();
- }
- else if (s[i] == '>' && e.size() > 0){
- f.push_back(e.front());
- e.pop_front();
- }
- else if (s[i] == '-' && f.size() > 0)
- f.pop_back();
- else if (s[i] != '>' && s[i] != '<' && s[i] != '-')
- f.push_back(s[i]);
- while (!f.empty()){
- cout << f.front();
- f.pop_front();
- }
- while (!e.empty()){
- cout << e.front();
- e.pop_front();
- }
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement