Advertisement
Asif_Anwar

Timus-1654. Cipher Message

May 13th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstdlib>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <vector>
  7. #include <set>
  8. #include <map>
  9. #include <stack>
  10. //#include <unordered_set>
  11. //#include <unordered_map>
  12. #include <queue>
  13. //#include <ctime>
  14. //#include <cassert>
  15. //#include <complex>
  16. #include <string>
  17. #include <cstring>
  18. //#include <chrono>
  19. //#include <random>
  20. #include <bitset>
  21. using namespace std;
  22. //using namespace chrono;
  23. #define pb push_back
  24. #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  25. #define F first
  26. #define S second
  27. typedef long long ll;
  28. typedef vector< int > vi;
  29. typedef vector< ll > V;
  30. typedef map<int, int > mp;
  31. #define debug cout << -1 << endl;
  32. #define REP(i, a, b) for(int i=a; i<b; i++)
  33. #define f0r(i, n) for (int i = 0; i < n; ++i)
  34. #define fore(a, x) for (auto& a : x)
  35. #define fori(i, a, b) for (int i = (a); i < (b); ++i)
  36. //#define pop pop_back
  37. #define sz(a) (int)a.size()
  38. //#define fin cin
  39. //#define fout cout
  40. const ll MOD = 1000000007;
  41. const int INF = (int)1e9;
  42. int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
  43. int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
  44. const double PI = acos(-1.0);
  45. const double diff = 1e-6;
  46.  
  47.  
  48. void solve()
  49. {
  50. //FastIO;
  51. //freopen("mowing.in","r",stdin);
  52. //freopen("mowing.out","w",stdout);
  53. string str;
  54. cin >> str;
  55. int n = str.size();
  56. stack< char > s;
  57. for(int i=0; i<n; i++) {
  58. if(!s.empty()) {
  59. if(s.top()==str[i]) {
  60. s.pop();
  61. continue;
  62. }
  63. }
  64. s.push(str[i]);
  65. }
  66. string ans;
  67. while(!s.empty()) {
  68. ans += s.top();
  69. s.pop();
  70. }
  71. reverse(ans.begin(), ans.end());
  72. cout << ans << "\n";
  73. }
  74.  
  75. int main()
  76. {
  77. int t;
  78. t = 1;
  79. //cin >> t;
  80. while(t--) {
  81. solve();
  82. }
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement