103932024-04-01 18:58:31Valaki2Mexxcpp17Wrong answer 0/100119ms13272 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++;
        }
    }
    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
1Wrong answer3ms1828 KiB
2Wrong answer3ms2056 KiB
subtask20/8
3Wrong answer3ms2244 KiB
4Wrong answer3ms2448 KiB
5Wrong answer3ms2532 KiB
6Wrong answer3ms2656 KiB
7Accepted3ms2868 KiB
8Wrong answer3ms3076 KiB
9Wrong answer3ms3288 KiB
10Wrong answer2ms3376 KiB
11Accepted2ms3476 KiB
subtask30/16
12Wrong answer3ms3504 KiB
13Wrong answer2ms3592 KiB
14Wrong answer3ms3716 KiB
15Accepted3ms3828 KiB
16Accepted3ms3900 KiB
subtask40/32
17Wrong answer4ms3968 KiB
18Wrong answer4ms3972 KiB
19Wrong answer4ms3964 KiB
20Wrong answer4ms3964 KiB
21Wrong answer4ms3968 KiB
22Wrong answer4ms3968 KiB
23Accepted3ms3936 KiB
24Accepted3ms4192 KiB
subtask50/44
25Wrong answer118ms12732 KiB
26Wrong answer116ms12568 KiB
27Wrong answer119ms12768 KiB
28Wrong answer116ms12812 KiB
29Wrong answer119ms13148 KiB
30Wrong answer119ms13100 KiB
31Wrong answer118ms13148 KiB
32Wrong answer119ms13056 KiB
33Wrong answer119ms13224 KiB
34Wrong answer118ms13272 KiB
35Wrong answer119ms13216 KiB
36Accepted64ms8924 KiB
37Accepted64ms8920 KiB