-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj1406.cpp
More file actions
38 lines (37 loc) · 780 Bytes
/
boj1406.cpp
File metadata and controls
38 lines (37 loc) · 780 Bytes
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
#include<bits/stdc++.h>
using namespace std;
list<char> edit;
string a;
int m;
int main(){
cin >> a;
for(auto i:a){
edit.push_back(i);
}
auto t=edit.end();
cin >> m;
while(m--){
char tmp;
cin >> tmp;
switch(tmp){
case 'P':
char add;
cin >> add;
edit.insert(t,add);
break;
case 'L':
if(t!=edit.begin()) t--;
break;
case 'D':
if(t!=edit.end()) t++;
break;
case 'B':
if(t!=edit.begin())
{
t=edit.erase(--t);
}
break;
}
}
for(auto i:edit) cout <<i;
}