Advertisement
Guest User

Untitled

a guest
May 5th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <vector>
  3. #include <map>
  4. #include <set>
  5. #include <complex>
  6. #include <ctime>
  7. #include <iostream>
  8. #include <cmath>
  9. #include <stack>
  10. #include <sstream>
  11. #include <stdio.h>
  12. #include <algorithm>
  13. #include <queue>
  14. #include <cstring>
  15. #include <cassert>
  16.  
  17.  
  18. const long double PI(acosl(-1.0));
  19.  
  20. #define pb push_back
  21. #define mp(a,b) make_pair(a,b)
  22. #define all(x) x.begin(), x.end()
  23. #define sqr(x) ((x)*(x))
  24. #define F first
  25. #define S second
  26. #define eps 1e-7
  27. #define inf (int)(1e9+7)
  28. #define infll (ll)(1e18+3)
  29. #define sz(x) ((int)x.size())
  30. #define bits(x) __builtin_popcount(x)
  31. #define bitsl(x) __builtin_popcountll(x)
  32.  
  33.  
  34. using namespace std;
  35. typedef unsigned long long ull;
  36. typedef long long ll;
  37. typedef long double ld;
  38. typedef vector < ll > vll;
  39. typedef vector<int> vi;
  40. typedef pair < ll, ll > pll;
  41. typedef pair < int, int > pii;
  42. typedef vector<vi> vii;
  43. typedef int huint;
  44.  
  45.  
  46. set<pair<int, char>> st;
  47.  
  48. int main()
  49. {
  50.  
  51. ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  52. // freopen("input.txt", "r", stdin);
  53. // freopen("output.txt", "w", stdout);
  54.  
  55. int n, m, p;
  56. cin >> n >> m >> p;
  57.  
  58. for (int i(0); i < n; i++)
  59. {
  60. char c;
  61. cin >> c;
  62. st.insert({ i + 1,c });
  63. }
  64.  
  65. auto pz = st.begin();
  66. for (int i(1); i < p; i++)
  67. pz++;
  68. for (int i(0); i < m; i++)
  69. {
  70. char c;
  71. cin >> c;
  72. if (c == 'R')
  73. pz++;
  74. if (c == 'L')
  75. pz--;
  76. if (c == 'D')
  77. {
  78. int s = 1;
  79. if (pz->S == '(')
  80. {
  81. while (s != 0)
  82. {
  83. auto pr = pz;
  84. pz++;
  85. if (pz->S == '(') s++;
  86. else s--;
  87. st.erase(pr);
  88. }
  89. auto pr = pz;
  90. pz++;
  91. st.erase(pr);
  92. if (pz == st.end()) pz--;
  93. }
  94. else
  95. {
  96. while (s != 0)
  97. {
  98. auto pr = pz;
  99. pz--;
  100. if (pz->S == ')') s++;
  101. else s--;
  102. st.erase(pr);
  103. }
  104. auto pr = pz;
  105. pz++;
  106. st.erase(pr);
  107. if (pz == st.end()) pz--;
  108. }
  109. }
  110. }
  111.  
  112. for (auto i = st.begin(); i != st.end(); i++)
  113. cout << i->S;
  114.  
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement