-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1406.cpp
More file actions
69 lines (58 loc) ยท 1.21 KB
/
1406.cpp
File metadata and controls
69 lines (58 loc) ยท 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define endl "\n"
#define MAX 1e9
struct coordinate {
int x;
int y;
};
struct FISH {
int x;
int y;
int Dir;
bool live;
};
//int dx[] = {0, 1, -1, 0, 1, -1, -1, 1};
//int dy[] = {1, 0, 0, -1, -1, 1, -1, 1};
int dx[] = {0, -1, -1, 0, 1, 1, 1, 0, -1};
int dy[] = {0,0, -1, -1, -1, 0, 1, 1, 1};
//int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2};
//int dy[] = {-1, 1, -2, 2, -2, 2, -1, 1};
int M;
void input() {
string s;
cin >> s >> M;
list<char> li(s.begin(), s.end());
auto idx = li.end();
for(int i = 0; i < M; i++) {
char a;
cin >> a;
if(a == 'L') {
if(idx != li.begin()) idx--;
}
else if(a == 'D') {
if(idx != li.end()) idx++;
}
else if(a == 'B') {
if(idx != li.begin()) {
idx--;
idx = li.erase(idx);
}
}
else {
char b;
cin >> b;
li.insert(idx, b);
}
}
for(auto it : li) {
cout << it;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
input();
}