#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0), ios::sync_with_stdio(0);
int n;
cin >> n;
vector<int> a(n);
for (int &ai : a) cin >> ai;
vector<int> b(n, -1);
vector<bool> used(n + 1);
for (int i = 0; i < n; i++) {
int ap = i == 0 ? 0 : a[i - 1];
if (ap > a[i] || a[i] > i + 1) {
cout << "NEM";
return 0;
}
if (ap < a[i]) {
b[i] = a[i - 1];
used[b[i]] = true;
}
}
used[a[n - 1]] = true; // don't use last value
int val = 0;
for (int i = 0; i < n; i++) {
if (b[i] != -1) continue;
while (used[val]) val++;
b[i] = val;
used[val] = true;
}
cout << "IGEN\n";
for (int &bi : b) cout << bi << ' ';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1692 KiB | ||||
2 | Accepted | 3ms | 1872 KiB | ||||
subtask2 | 8/8 | ||||||
3 | Accepted | 3ms | 1872 KiB | ||||
4 | Accepted | 3ms | 2080 KiB | ||||
5 | Accepted | 2ms | 2164 KiB | ||||
6 | Accepted | 3ms | 2292 KiB | ||||
7 | Accepted | 2ms | 2376 KiB | ||||
8 | Accepted | 3ms | 2780 KiB | ||||
9 | Accepted | 3ms | 2636 KiB | ||||
10 | Accepted | 2ms | 2632 KiB | ||||
11 | Accepted | 2ms | 2524 KiB | ||||
12 | Accepted | 3ms | 2652 KiB | ||||
subtask3 | 16/16 | ||||||
13 | Accepted | 3ms | 2652 KiB | ||||
14 | Accepted | 3ms | 2856 KiB | ||||
15 | Accepted | 3ms | 3060 KiB | ||||
16 | Accepted | 2ms | 3148 KiB | ||||
17 | Accepted | 3ms | 3276 KiB | ||||
18 | Accepted | 3ms | 3504 KiB | ||||
subtask4 | 32/32 | ||||||
19 | Accepted | 3ms | 3504 KiB | ||||
20 | Accepted | 4ms | 3908 KiB | ||||
21 | Accepted | 4ms | 3904 KiB | ||||
22 | Accepted | 4ms | 4028 KiB | ||||
23 | Accepted | 4ms | 4248 KiB | ||||
24 | Accepted | 4ms | 4200 KiB | ||||
25 | Accepted | 4ms | 4464 KiB | ||||
26 | Accepted | 3ms | 4408 KiB | ||||
27 | Accepted | 3ms | 4456 KiB | ||||
subtask5 | 44/44 | ||||||
28 | Accepted | 3ms | 4456 KiB | ||||
29 | Accepted | 101ms | 12216 KiB | ||||
30 | Accepted | 101ms | 12380 KiB | ||||
31 | Accepted | 101ms | 12352 KiB | ||||
32 | Accepted | 101ms | 12088 KiB | ||||
33 | Accepted | 101ms | 12092 KiB | ||||
34 | Accepted | 101ms | 12036 KiB | ||||
35 | Accepted | 103ms | 12044 KiB | ||||
36 | Accepted | 101ms | 12096 KiB | ||||
37 | Accepted | 104ms | 12096 KiB | ||||
38 | Accepted | 103ms | 12216 KiB | ||||
39 | Accepted | 104ms | 12208 KiB | ||||
40 | Accepted | 56ms | 12148 KiB | ||||
41 | Accepted | 57ms | 12064 KiB |