提交时间:2024-01-07 15:25:51

运行 ID: 230063

#include<bits/stdc++.h> using namespace std; queue<int>q; bool vis[1000002]; int n,m; int main() { scanf("%d%d",&n,&m); for(int i=1; i<=n; i++) vis[i]=false; for(int i=1; i<=m; i++) { int t; scanf("%d",&t); if(vis[t]==false) { q.push(t); vis[t]=true; } } while(!q.empty()) { int u=q.front(); q.pop(); printf("%d ",u); } for(int i=1; i<=n; i++) { if(vis[i]==false) printf("%d ",i); } return 0; }