提交时间:2024-01-07 13:53:23
运行 ID: 229917
#include <iostream> #include <map> using namespace std; map<int, int> a, b; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { a[i] = i; b[i] = i; } int idx(0); while (m--) { int t; cin >> t; a[--idx] = t; a.erase(b[t]); b[t] = idx; } for (auto &v: a) { cout << v.second << ' '; } }