0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 13:58:48 +00:00
Baoshuo Ren 2021-08-27 17:18:17 +08:00 committed by Baoshuo Ren
parent 2ea750984c
commit 01ab18dd50
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

39
AcWing/827/827.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <bits/stdc++.h>
using namespace std;
int m, x, k, p;
string op;
list<int> a;
list<int>::iterator it[100005];
int main() {
cin >> m;
while (m--) {
cin >> op;
if (op == "L") {
cin >> x;
a.push_front(x);
it[++p] = a.begin();
} else if (op == "R") {
cin >> x;
a.push_back(x);
it[++p] = --a.end();
} else if (op == "D") {
cin >> k;
a.erase(it[k]);
} else if (op == "IL") {
cin >> k >> x;
it[++p] = a.insert(it[k], x);
} else {
cin >> k >> x;
auto itk = it[k];
it[++p] = a.insert(++itk, x);
}
}
for (int i : a) {
cout << i << ' ';
}
cout << endl;
return 0;
}