0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 20:05:26 +00:00
Baoshuo Ren 2021-08-24 21:13:14 +08:00 committed by Baoshuo Ren
parent 8f84512bb8
commit 8dda40185b
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

37
AcWing/826/826.cpp Normal file
View File

@ -0,0 +1,37 @@
#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;
}