#include <iostream>
#include <stack>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
string s; cin >> s;
int t; cin >> t;
stack<char>left, right;
for (int i = 0; i < s.length(); i++) {
left.push(s[i]);
}
while (t--) {
char com; cin >> com;
if (com == 'L') {
if (left.empty()) continue;
right.push(left.top());
left.pop();
}
else if (com == 'D') {
if (right.empty()) continue;
left.push(right.top());
right.pop();
}
else if (com == 'B') {
if (!left.empty()) left.pop();
}
else if (com == 'P') {
char c; cin >> c;
left.push(c);
}
}
while (!left.empty()) {
right.push(left.top());
left.pop();
}
while (!right.empty()) {
cout << right.top();
right.pop();
}
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 14284๋ฒ - ๊ฐ์ ์ด์ด๊ฐ๊ธฐ2 (0) | 2021.11.06 |
---|---|
[๋ฐฑ์ค,c++] 1427๋ฒ - ์ํธ์ธ์ฌ์ด๋ (0) | 2021.11.06 |
[๋ฐฑ์ค,c++] 14241๋ฒ - ์ฌ๋ผ์ ํฉ์น๊ธฐ (0) | 2021.11.06 |
[๋ฐฑ์ค,c++] 13913๋ฒ - ์จ๋ฐ๊ผญ์ง4 (0) | 2021.11.06 |
[๋ฐฑ์ค,c++] 1389๋ฒ - ์ผ๋น ๋ฒ ์ด์ปจ์ 6๋จ๊ณ ๋ฒ์น (0) | 2021.11.06 |
[๋ฐฑ์ค,c++] 1377๋ฒ - ๋ฒ๋ธ ์ํธ (0) | 2021.11.06 |
๋๊ธ