103942024-04-01 18:59:08Valaki2Mexxcpp17Accepted 100/100120ms12872 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

void solve() {
    int n;
    cin >> n;
    vector<int> a(1 + n, 0);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++) {
        if(a[i] < a[i - 1] || a[i] >= i + 1) {
            cout << "NEM\n";
            return;
        }
    }
    vector<bool> used(1 + 2 * n, false);
    for(int i = 0; i <= n; i++) {
        used[a[i]] = true;
    }
    vector<int> b(1 + n, 0);
    int nxt_unused = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i] != a[i - 1]) {
            b[i] = a[i - 1];
        } else {
            while(used[nxt_unused]) {
                nxt_unused++;
            }
            b[i] = nxt_unused;
            nxt_unused++;
        }
    }
    cout << "IGEN\n";
    for(int i = 1; i <= n; i++) {
        cout << b[i] << " ";
    }
    cout << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2020 KiB
subtask28/8
3Accepted3ms2248 KiB
4Accepted2ms2336 KiB
5Accepted2ms2324 KiB
6Accepted3ms2600 KiB
7Accepted3ms2476 KiB
8Accepted3ms2672 KiB
9Accepted3ms2872 KiB
10Accepted3ms3104 KiB
11Accepted3ms3172 KiB
subtask316/16
12Accepted3ms3304 KiB
13Accepted3ms3508 KiB
14Accepted3ms3596 KiB
15Accepted3ms3600 KiB
16Accepted3ms3696 KiB
subtask432/32
17Accepted4ms4012 KiB
18Accepted4ms3880 KiB
19Accepted4ms3884 KiB
20Accepted4ms3892 KiB
21Accepted4ms3900 KiB
22Accepted4ms3884 KiB
23Accepted3ms4100 KiB
24Accepted3ms4312 KiB
subtask544/44
25Accepted118ms12340 KiB
26Accepted118ms12420 KiB
27Accepted118ms12664 KiB
28Accepted116ms12444 KiB
29Accepted119ms12556 KiB
30Accepted119ms12812 KiB
31Accepted119ms12796 KiB
32Accepted119ms12872 KiB
33Accepted118ms12768 KiB
34Accepted120ms12716 KiB
35Accepted119ms12764 KiB
36Accepted65ms8376 KiB
37Accepted64ms8376 KiB