#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();
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2020 KiB | ||||
subtask2 | 8/8 | ||||||
3 | Accepted | 3ms | 2248 KiB | ||||
4 | Accepted | 2ms | 2336 KiB | ||||
5 | Accepted | 2ms | 2324 KiB | ||||
6 | Accepted | 3ms | 2600 KiB | ||||
7 | Accepted | 3ms | 2476 KiB | ||||
8 | Accepted | 3ms | 2672 KiB | ||||
9 | Accepted | 3ms | 2872 KiB | ||||
10 | Accepted | 3ms | 3104 KiB | ||||
11 | Accepted | 3ms | 3172 KiB | ||||
subtask3 | 16/16 | ||||||
12 | Accepted | 3ms | 3304 KiB | ||||
13 | Accepted | 3ms | 3508 KiB | ||||
14 | Accepted | 3ms | 3596 KiB | ||||
15 | Accepted | 3ms | 3600 KiB | ||||
16 | Accepted | 3ms | 3696 KiB | ||||
subtask4 | 32/32 | ||||||
17 | Accepted | 4ms | 4012 KiB | ||||
18 | Accepted | 4ms | 3880 KiB | ||||
19 | Accepted | 4ms | 3884 KiB | ||||
20 | Accepted | 4ms | 3892 KiB | ||||
21 | Accepted | 4ms | 3900 KiB | ||||
22 | Accepted | 4ms | 3884 KiB | ||||
23 | Accepted | 3ms | 4100 KiB | ||||
24 | Accepted | 3ms | 4312 KiB | ||||
subtask5 | 44/44 | ||||||
25 | Accepted | 118ms | 12340 KiB | ||||
26 | Accepted | 118ms | 12420 KiB | ||||
27 | Accepted | 118ms | 12664 KiB | ||||
28 | Accepted | 116ms | 12444 KiB | ||||
29 | Accepted | 119ms | 12556 KiB | ||||
30 | Accepted | 119ms | 12812 KiB | ||||
31 | Accepted | 119ms | 12796 KiB | ||||
32 | Accepted | 119ms | 12872 KiB | ||||
33 | Accepted | 118ms | 12768 KiB | ||||
34 | Accepted | 120ms | 12716 KiB | ||||
35 | Accepted | 119ms | 12764 KiB | ||||
36 | Accepted | 65ms | 8376 KiB | ||||
37 | Accepted | 64ms | 8376 KiB |