0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-05 02:26:26 +00:00
OI-codes/AcWing/826/826.cpp

38 lines
724 B
C++

#include <bits/stdc++.h>
using namespace std;
int m, k, x, t;
char op;
list<int> a;
list<int>::iterator it[100005];
int main() {
cin >> m;
while (m--) {
cin >> op;
if (op == 'H') {
cin >> x;
a.push_front(x);
it[++t] = a.begin();
} else if (op == 'D') {
cin >> k;
if (k == 0) {
a.pop_front();
} else {
auto itk = it[k];
a.erase(++itk);
}
} else {
cin >> k >> x;
auto itk = it[k];
it[++t] = a.insert(++itk, x);
}
}
for (int i : a) {
cout << i << ' ';
}
cout << endl;
return 0;
}