比赛 期末考试3 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 hope I can be awake 最终得分 100
用户昵称 djyqjy 运行时间 0.206 s
代码语言 C++ 内存使用 4.07 MiB
提交时间 2026-02-11 09:09:59
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
#define pir pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
inline int re()
{
    int f=1,num=0;
    char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9') num=num*10+c-'0',c=getchar();
    return num*f;
}
int T;
void clear();
const int N=200010;
int n,k;
int a[N];
vector<int> ans;
queue<int> q;
vector<int> tmp;
void work()
{
    freopen("hopeicanbeawake.in","r",stdin);
    freopen("hopeicanbeawake.out","w",stdout);
    clear();
    n=re();k=re();
    for(int i=1;i<=k;i++) a[i]=re();
    for(int i=1;i<k;i++)
    {
        for(int j=a[i-1]+1;j<a[i];j++) q.push(j);
        ans.pb(a[i]);
        if(!q.empty()) ans.pb(q.front()),q.pop();
    }
    while(!q.empty()) tmp.pb(q.front()),q.pop();
    for(int j=a[k-1]+1;j<=n;j++) tmp.pb(j);

    // cout<<"***"<<endl;
    // for(int x:tmp) cout<<x<<' ';cout<<endl;
    // for(int x:ans) cout<<x<<' ';cout<<endl;
    // cout<<"***"<<endl;

    for(int i=tmp.size()-1;i>=0;i--)
    {
        ans.pb(tmp[i]);
    }
    for(int x:ans) printf("%d ",x);
    return;
}
int main()
{
    T=1;
    while(T--) work();
    return 0;
}
void clear()
{
    return;
}