0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 23:16:30 +00:00
OI-codes/AcWing/826/826.cpp

38 lines
724 B
C++
Raw Normal View History

#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;
}