From 8dda40185b2be20f4149d30be4352330fb9efd6d Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Tue, 24 Aug 2021 21:13:14 +0800 Subject: [PATCH] =?UTF-8?q?826.=20=E5=8D=95=E9=93=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/7357618/ --- AcWing/826/826.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 AcWing/826/826.cpp 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; +}