提交时间:2024-01-07 16:16:13
运行 ID: 230124
#include <bits/stdc++.h> using namespace std; int n,m,t; stack<int>a; bool b[1000006]={0}; int main() { cin >>n >> m; for (int i=1;i<=m;i++) { cin >> t; a.push(t); } for (int i=1;!a.empty();i++) { if (b[a.top()]==0) { cout << a.top() << ' '; b[a.top()]=1; } a.pop(); } for (int i=1;i<=n;i++) { if (b[i]==0) { cout << i << ' '; } } return 0; }