#include <bits/stdc++.h>
using namespace std;
int n, a[500001], b[500001];
bool c[1000001];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin>> n;
for(int i = 1; i <= n; i++) {
cin>> a[i];
b[i] = -1;
c[a[i]] = true;
}
c[0] = true;
for(int i = 1; i < n; i++)
if(a[i+1] > a[i])
b[i+1] = a[i];
int szam = 0;
bool jo = true;
for(int i = 1; i <= n; i++) {
while(c[szam]) szam++;
if(b[i] == -1) {
b[i] = szam;
szam++;
} else if(szam < a[i]-1)
jo = false;
if(i > 1 && a[i] < a[i-1]) jo = false;
}
if(!jo || szam < a[n]-1) cout << "NEM";
else {
cout << "IGEN\n";
for(int i = 1; i <= n; i++) cout << b[i] << ' ';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 2176 KiB | ||||
2 | Partially correct | 3ms | 2336 KiB | ||||
subtask2 | 0/8 | ||||||
3 | Accepted | 3ms | 2652 KiB | ||||
4 | Accepted | 3ms | 2800 KiB | ||||
5 | Partially correct | 3ms | 2884 KiB | ||||
6 | Accepted | 3ms | 3064 KiB | ||||
7 | Wrong answer | 2ms | 3144 KiB | ||||
8 | Partially correct | 3ms | 3320 KiB | ||||
9 | Accepted | 2ms | 3276 KiB | ||||
10 | Partially correct | 2ms | 3280 KiB | ||||
11 | Accepted | 3ms | 3352 KiB | ||||
subtask3 | 0/16 | ||||||
12 | Partially correct | 3ms | 3160 KiB | ||||
13 | Partially correct | 3ms | 3288 KiB | ||||
14 | Partially correct | 3ms | 3632 KiB | ||||
15 | Wrong answer | 3ms | 3840 KiB | ||||
16 | Accepted | 3ms | 3952 KiB | ||||
subtask4 | 8/32 | ||||||
17 | Partially correct | 4ms | 4148 KiB | ||||
18 | Partially correct | 4ms | 4004 KiB | ||||
19 | Partially correct | 4ms | 4136 KiB | ||||
20 | Partially correct | 4ms | 4252 KiB | ||||
21 | Partially correct | 4ms | 4260 KiB | ||||
22 | Partially correct | 4ms | 4248 KiB | ||||
23 | Accepted | 3ms | 4120 KiB | ||||
24 | Accepted | 3ms | 4092 KiB | ||||
subtask5 | 11/44 | ||||||
25 | Accepted | 103ms | 12776 KiB | ||||
26 | Partially correct | 104ms | 13072 KiB | ||||
27 | Partially correct | 104ms | 13092 KiB | ||||
28 | Partially correct | 104ms | 13212 KiB | ||||
29 | Partially correct | 104ms | 13408 KiB | ||||
30 | Partially correct | 105ms | 13500 KiB | ||||
31 | Partially correct | 104ms | 13304 KiB | ||||
32 | Partially correct | 104ms | 13212 KiB | ||||
33 | Partially correct | 107ms | 13268 KiB | ||||
34 | Partially correct | 105ms | 13348 KiB | ||||
35 | Partially correct | 108ms | 13160 KiB | ||||
36 | Accepted | 61ms | 12556 KiB | ||||
37 | Accepted | 63ms | 12532 KiB |