diff --git a/AcWing/826/826.cpp b/AcWing/826/826.cpp new file mode 100644 index 00000000..dbd1fe45 --- /dev/null +++ b/AcWing/826/826.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; + +int m, k, x, t; +char op; +list a; +list::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; +}