#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int MAXN = 500001;
int v[MAXN], b[MAXN], ans[MAXN];
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
fill(ans, ans+MAXN, n+1);
for (int i = 1; i <= n; i++) {
cin >> v[i];
}
for (int i = 2; i <= n; i++) {
if (v[i-1] > v[i]) {
cout << "NEM\n";
return 0;
}
}
vector<int> idx;
int x = 0;
for (int i = 1; i <= n; i++) {
idx.push_back(i);
if (v[i] != v[i-1]) {
for (; x < v[i]; x++) {
if (idx.empty()) {
cout << "NEM\n";
return 0;
}
ans[idx.back()] = x;
idx.pop_back();
}
}
}
cout << "IGEN\n";
for (int i = 1; i <= n; i++) {
cout << ans[i] << " ";
}
cout << "\n";
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 4ms | 5832 KiB | ||||
2 | Accepted | 4ms | 6152 KiB | ||||
subtask2 | 8/8 | ||||||
3 | Accepted | 4ms | 6152 KiB | ||||
4 | Accepted | 4ms | 6240 KiB | ||||
5 | Accepted | 4ms | 6192 KiB | ||||
6 | Accepted | 4ms | 6528 KiB | ||||
7 | Accepted | 4ms | 6716 KiB | ||||
8 | Accepted | 4ms | 6884 KiB | ||||
9 | Accepted | 4ms | 6836 KiB | ||||
10 | Accepted | 4ms | 7100 KiB | ||||
11 | Accepted | 4ms | 7012 KiB | ||||
12 | Accepted | 4ms | 7016 KiB | ||||
subtask3 | 16/16 | ||||||
13 | Accepted | 4ms | 7016 KiB | ||||
14 | Accepted | 4ms | 7004 KiB | ||||
15 | Accepted | 4ms | 7016 KiB | ||||
16 | Accepted | 4ms | 7312 KiB | ||||
17 | Accepted | 4ms | 7268 KiB | ||||
18 | Accepted | 4ms | 7220 KiB | ||||
subtask4 | 32/32 | ||||||
19 | Accepted | 4ms | 7220 KiB | ||||
20 | Accepted | 4ms | 7372 KiB | ||||
21 | Accepted | 4ms | 7516 KiB | ||||
22 | Accepted | 4ms | 7616 KiB | ||||
23 | Accepted | 4ms | 7760 KiB | ||||
24 | Accepted | 6ms | 7800 KiB | ||||
25 | Accepted | 4ms | 7812 KiB | ||||
26 | Accepted | 4ms | 7760 KiB | ||||
27 | Accepted | 4ms | 7748 KiB | ||||
subtask5 | 44/44 | ||||||
28 | Accepted | 4ms | 7748 KiB | ||||
29 | Accepted | 98ms | 12092 KiB | ||||
30 | Accepted | 97ms | 12076 KiB | ||||
31 | Accepted | 98ms | 11972 KiB | ||||
32 | Accepted | 98ms | 12076 KiB | ||||
33 | Accepted | 98ms | 12056 KiB | ||||
34 | Accepted | 98ms | 12076 KiB | ||||
35 | Accepted | 98ms | 11936 KiB | ||||
36 | Accepted | 100ms | 12048 KiB | ||||
37 | Accepted | 98ms | 12116 KiB | ||||
38 | Accepted | 100ms | 12116 KiB | ||||
39 | Accepted | 101ms | 12068 KiB | ||||
40 | Accepted | 57ms | 13188 KiB | ||||
41 | Accepted | 56ms | 11804 KiB |