#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
FastIO;
bool ok, same;
ll i, j, rs, N;
cin >> N;
vector<ll> lucky(N);
for(i = 0; i < N; i++)
cin >> lucky[i];
rs = -1;
ok = same = true;
vector<ll> ans(N, 0);
stack<ll> free_places;
for(i = 1; i < N; i++) {
if(lucky[i] == lucky[i - 1])
continue;
same = false;
if(lucky[i] - lucky[i - 1] > i - rs + free_places.size()) {
ok = false;
break;
}
for(j = 0; j < min(lucky[i] - lucky[i - 1], i - rs); j++)
ans[i - j] = j + lucky[i - 1];
while(j < i - rs)
free_places.push(i - j++);
while(j < lucky[i] - lucky[i - 1]) {
ans[free_places.top()] = j++ + lucky[i - 1];
free_places.pop();
}
rs = i;
}
if(same) {
switch(lucky[0]) {
case 0:
ok = true;
fill(all(ans), 1);
break;
case 1:
ok = true;
break;
default:
ok = false;
}
}
if(ok) {
cout << "IGEN\n";
for(const auto &x : ans)
cout << x << ' ';
cout << '\n';
}
else
cout << "NEM\n";
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1860 KiB | ||||
2 | Accepted | 3ms | 2024 KiB | ||||
subtask2 | 2/8 | ||||||
3 | Accepted | 3ms | 2236 KiB | ||||
4 | Partially correct | 3ms | 2448 KiB | ||||
5 | Accepted | 3ms | 2668 KiB | ||||
6 | Partially correct | 3ms | 3016 KiB | ||||
7 | Accepted | 3ms | 3016 KiB | ||||
8 | Accepted | 3ms | 3096 KiB | ||||
9 | Accepted | 2ms | 3204 KiB | ||||
10 | Accepted | 3ms | 3308 KiB | ||||
11 | Accepted | 3ms | 3164 KiB | ||||
subtask3 | 16/16 | ||||||
12 | Accepted | 3ms | 3168 KiB | ||||
13 | Accepted | 2ms | 3164 KiB | ||||
14 | Accepted | 3ms | 3164 KiB | ||||
15 | Accepted | 3ms | 3288 KiB | ||||
16 | Accepted | 3ms | 3504 KiB | ||||
subtask4 | 32/32 | ||||||
17 | Accepted | 4ms | 3832 KiB | ||||
18 | Accepted | 4ms | 3832 KiB | ||||
19 | Accepted | 4ms | 3968 KiB | ||||
20 | Accepted | 4ms | 3832 KiB | ||||
21 | Accepted | 4ms | 4048 KiB | ||||
22 | Accepted | 4ms | 4192 KiB | ||||
23 | Accepted | 4ms | 4140 KiB | ||||
24 | Accepted | 3ms | 4132 KiB | ||||
subtask5 | 44/44 | ||||||
25 | Accepted | 114ms | 20028 KiB | ||||
26 | Accepted | 114ms | 19912 KiB | ||||
27 | Accepted | 112ms | 19856 KiB | ||||
28 | Accepted | 112ms | 19848 KiB | ||||
29 | Accepted | 112ms | 19940 KiB | ||||
30 | Accepted | 112ms | 19848 KiB | ||||
31 | Accepted | 112ms | 19848 KiB | ||||
32 | Accepted | 114ms | 20064 KiB | ||||
33 | Accepted | 112ms | 20076 KiB | ||||
34 | Accepted | 115ms | 20136 KiB | ||||
35 | Accepted | 115ms | 20204 KiB | ||||
36 | Accepted | 68ms | 21360 KiB | ||||
37 | Accepted | 65ms | 21632 KiB |