105762024-04-05 20:01:39UVinceMexxcpp17Accepted 100/100123ms12844 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

#define all(a) a.begin(),a.end()

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int> ans(n, -1);
    bool pos=true;
    vector<bool> has(2*n+1, false);
    for (int i=0;i<n;i++){
        cin>>v[i];
        if (i && v[i]<v[i-1]) pos=false;
        if (i && v[i]!=v[i-1]) ans[i]=v[i-1];
        has[v[i]]=true;
    }
    if (!pos){
        cout<<"NEM";
        return 0;
    }
    int cur=0;
    for (int i=0;i<n;i++){
        while (has[cur] && cur<=2*n) cur++;
        if (cur>2*n) cur=2*n;
        if (ans[i]==-1) {
            ans[i]=cur;
            cur++;
        }
    }
    cur=0;
    vector<bool> other(2*n+1,false);
    for (int i=0;i<n;i++){
        other[ans[i]]=true;
        while(other[cur] && cur<=2*n) cur++;
        if (cur!=v[i]) pos=false;
    }
    if (pos){
        cout<<"IGEN\n";
        for (int i : ans) cout<<i<<" ";
    }
    else {
        cout<<"NEM";
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1700 KiB
2Accepted3ms1936 KiB
subtask28/8
3Accepted3ms2136 KiB
4Accepted3ms2228 KiB
5Accepted3ms2156 KiB
6Accepted3ms2288 KiB
7Accepted3ms2520 KiB
8Accepted3ms2596 KiB
9Accepted3ms2728 KiB
10Accepted3ms2940 KiB
11Accepted3ms3148 KiB
subtask316/16
12Accepted3ms3232 KiB
13Accepted3ms3228 KiB
14Accepted3ms3460 KiB
15Accepted3ms3444 KiB
16Accepted3ms3696 KiB
subtask432/32
17Accepted4ms3912 KiB
18Accepted4ms4124 KiB
19Accepted4ms4064 KiB
20Accepted4ms3952 KiB
21Accepted4ms3948 KiB
22Accepted4ms3972 KiB
23Accepted3ms3964 KiB
24Accepted3ms3996 KiB
subtask544/44
25Accepted116ms12220 KiB
26Accepted115ms12160 KiB
27Accepted115ms12264 KiB
28Accepted116ms12348 KiB
29Accepted116ms12408 KiB
30Accepted116ms12308 KiB
31Accepted119ms12372 KiB
32Accepted119ms12552 KiB
33Accepted119ms12532 KiB
34Accepted120ms12796 KiB
35Accepted123ms12844 KiB
36Accepted70ms12684 KiB
37Accepted64ms12548 KiB