Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <vector>
- #include <map>
- #include <set>
- #include <complex>
- #include <ctime>
- #include <iostream>
- #include <cmath>
- #include <stack>
- #include <sstream>
- #include <stdio.h>
- #include <algorithm>
- #include <queue>
- #include <cstring>
- #include <cassert>
- const long double PI(acosl(-1.0));
- #define pb push_back
- #define mp(a,b) make_pair(a,b)
- #define all(x) x.begin(), x.end()
- #define sqr(x) ((x)*(x))
- #define F first
- #define S second
- #define eps 1e-7
- #define inf (int)(1e9+7)
- #define infll (ll)(1e18+3)
- #define sz(x) ((int)x.size())
- #define bits(x) __builtin_popcount(x)
- #define bitsl(x) __builtin_popcountll(x)
- using namespace std;
- typedef unsigned long long ull;
- typedef long long ll;
- typedef long double ld;
- typedef vector < ll > vll;
- typedef vector<int> vi;
- typedef pair < ll, ll > pll;
- typedef pair < int, int > pii;
- typedef vector<vi> vii;
- typedef int huint;
- set<pair<int, char>> st;
- int main()
- {
- ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
- // freopen("input.txt", "r", stdin);
- // freopen("output.txt", "w", stdout);
- int n, m, p;
- cin >> n >> m >> p;
- for (int i(0); i < n; i++)
- {
- char c;
- cin >> c;
- st.insert({ i + 1,c });
- }
- auto pz = st.begin();
- for (int i(1); i < p; i++)
- pz++;
- for (int i(0); i < m; i++)
- {
- char c;
- cin >> c;
- if (c == 'R')
- pz++;
- if (c == 'L')
- pz--;
- if (c == 'D')
- {
- int s = 1;
- if (pz->S == '(')
- {
- while (s != 0)
- {
- auto pr = pz;
- pz++;
- if (pz->S == '(') s++;
- else s--;
- st.erase(pr);
- }
- auto pr = pz;
- pz++;
- st.erase(pr);
- if (pz == st.end()) pz--;
- }
- else
- {
- while (s != 0)
- {
- auto pr = pz;
- pz--;
- if (pz->S == ')') s++;
- else s--;
- st.erase(pr);
- }
- auto pr = pz;
- pz++;
- st.erase(pr);
- if (pz == st.end()) pz--;
- }
- }
- }
- for (auto i = st.begin(); i != st.end(); i++)
- cout << i->S;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement