Advertisement
sherry_ahmos

Untitled

May 5th, 2022
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <cstdlib>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <iomanip>
  7. #include <numeric>
  8. #include <vector>
  9. #include <string>
  10. #include <set>
  11. #include <map>
  12. #include <stack>
  13. #include <deque>
  14.  
  15. using namespace std;
  16. #define ll long long
  17. void sherry()
  18. {
  19.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  20. #ifndef ONLINE_JUDGE
  21.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  22. #endif
  23. }
  24. /*bool comp(pair<int, int> a, pair<int, int> b)
  25. {
  26.     return a.second < b.second;
  27. }*/
  28. int main()
  29. {
  30.     sherry();
  31.     stack<char> s;
  32.     string c;
  33.     getline(cin, c);
  34.     s.push(c[0]);
  35.     for (ll i = 1; i < c.size(); i++)
  36.     {
  37.         if (c[i] == s.top())
  38.             s.pop();
  39.         else
  40.         {
  41.             s.push(c[i]);
  42.         }
  43.     }
  44.     for (size_t i = 0; !s.empty(); i++)
  45.     {
  46.         cout << s.top();
  47.         s.pop();
  48.     }
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement