#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 = 0; 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 | 1900 KiB | ||||
2 | Accepted | 3ms | 2244 KiB | ||||
subtask2 | 0/8 | ||||||
3 | Accepted | 3ms | 2452 KiB | ||||
4 | Accepted | 3ms | 2660 KiB | ||||
5 | Accepted | 3ms | 3000 KiB | ||||
6 | Accepted | 3ms | 2956 KiB | ||||
7 | Wrong answer | 3ms | 3108 KiB | ||||
8 | Accepted | 3ms | 3304 KiB | ||||
9 | Accepted | 3ms | 3264 KiB | ||||
10 | Accepted | 3ms | 3392 KiB | ||||
11 | Accepted | 3ms | 3544 KiB | ||||
subtask3 | 0/16 | ||||||
12 | Accepted | 3ms | 3616 KiB | ||||
13 | Accepted | 3ms | 3688 KiB | ||||
14 | Accepted | 3ms | 3568 KiB | ||||
15 | Wrong answer | 3ms | 3644 KiB | ||||
16 | Accepted | 3ms | 3976 KiB | ||||
subtask4 | 32/32 | ||||||
17 | Accepted | 4ms | 4188 KiB | ||||
18 | Accepted | 4ms | 4396 KiB | ||||
19 | Accepted | 4ms | 4488 KiB | ||||
20 | Accepted | 4ms | 4468 KiB | ||||
21 | Accepted | 4ms | 4504 KiB | ||||
22 | Accepted | 4ms | 4492 KiB | ||||
23 | Accepted | 3ms | 4260 KiB | ||||
24 | Accepted | 3ms | 4528 KiB | ||||
subtask5 | 44/44 | ||||||
25 | Accepted | 105ms | 13124 KiB | ||||
26 | Accepted | 104ms | 13332 KiB | ||||
27 | Accepted | 104ms | 13284 KiB | ||||
28 | Accepted | 104ms | 13276 KiB | ||||
29 | Accepted | 105ms | 13356 KiB | ||||
30 | Accepted | 104ms | 13392 KiB | ||||
31 | Accepted | 104ms | 13492 KiB | ||||
32 | Accepted | 107ms | 13276 KiB | ||||
33 | Accepted | 107ms | 13356 KiB | ||||
34 | Accepted | 108ms | 13404 KiB | ||||
35 | Accepted | 108ms | 13356 KiB | ||||
36 | Accepted | 63ms | 12640 KiB | ||||
37 | Accepted | 63ms | 12596 KiB |