Advertisement
PikMike

Untitled

Sep 7th, 2016
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #define _USE_CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <string>
  4. #include <vector>
  5. #include <iostream>
  6. #include <map>
  7. #include <set>
  8. #include <algorithm>
  9. #include <math.h>
  10. #include <deque>
  11. #include <functional>
  12.  
  13. #define forn(i, n) for (int i = 0; i < int(n); i++)
  14. #define fore(i, s, n) for (int i = int(s); i < int(n); i++)
  15. #define all(a) (a).begin(), (a).end()
  16. #define sz(a) a.size()
  17. #define ft first
  18. #define sc second
  19. #define mp make_pair
  20. #define pb push_back
  21. #define ll long long
  22.  
  23. using namespace std;
  24.  
  25. deque<char> f, e;
  26.  
  27.  
  28. int main() {
  29.     #ifdef _DEBUG
  30.         freopen("input.txt", "r", stdin);
  31.         freopen("output.txt", "w", stdout);
  32.     #endif
  33.     int z;
  34.     cin >> z;
  35.     forn(z1, z){
  36.         string s;
  37.         cin >> s;  
  38.         int n = s.size();
  39.         forn(i, n)
  40.             if (s[i] == '<' && f.size() > 0){
  41.                 e.push_front(f.back());
  42.                 f.pop_back();
  43.             }
  44.             else if (s[i] == '>' && e.size() > 0){
  45.                 f.push_back(e.front());
  46.                 e.pop_front();
  47.             }
  48.             else if (s[i] == '-' && f.size() > 0)
  49.                 f.pop_back();
  50.             else if (s[i] != '>' && s[i] != '<' && s[i] != '-')
  51.                 f.push_back(s[i]);
  52.         while (!f.empty()){
  53.             cout << f.front();
  54.             f.pop_front();
  55.         }
  56.         while (!e.empty()){
  57.             cout << e.front();
  58.             e.pop_front();
  59.         }
  60.         cout << "\n";
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement