#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;
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]) {
if(free_places.empty())
goto done;
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;
}
}
done:;
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 | 1824 KiB | ||||
2 | Accepted | 3ms | 2028 KiB | ||||
subtask2 | 0/8 | ||||||
3 | Accepted | 3ms | 2236 KiB | ||||
4 | Partially correct | 2ms | 2320 KiB | ||||
5 | Accepted | 3ms | 2444 KiB | ||||
6 | Partially correct | 3ms | 2652 KiB | ||||
7 | Accepted | 2ms | 2892 KiB | ||||
8 | Accepted | 3ms | 2864 KiB | ||||
9 | Accepted | 3ms | 3076 KiB | ||||
10 | Accepted | 3ms | 3296 KiB | ||||
11 | Wrong answer | 3ms | 3516 KiB | ||||
subtask3 | 0/16 | ||||||
12 | Accepted | 3ms | 3736 KiB | ||||
13 | Accepted | 3ms | 3660 KiB | ||||
14 | Accepted | 3ms | 3652 KiB | ||||
15 | Wrong answer | 3ms | 3756 KiB | ||||
16 | Wrong answer | 3ms | 3652 KiB | ||||
subtask4 | 0/32 | ||||||
17 | Accepted | 4ms | 4032 KiB | ||||
18 | Accepted | 4ms | 4256 KiB | ||||
19 | Accepted | 4ms | 4184 KiB | ||||
20 | Accepted | 4ms | 4348 KiB | ||||
21 | Accepted | 4ms | 4424 KiB | ||||
22 | Accepted | 4ms | 4432 KiB | ||||
23 | Wrong answer | 4ms | 4440 KiB | ||||
24 | Wrong answer | 4ms | 4452 KiB | ||||
subtask5 | 0/44 | ||||||
25 | Accepted | 115ms | 20328 KiB | ||||
26 | Accepted | 115ms | 20204 KiB | ||||
27 | Accepted | 114ms | 20484 KiB | ||||
28 | Accepted | 115ms | 20444 KiB | ||||
29 | Accepted | 115ms | 20448 KiB | ||||
30 | Accepted | 115ms | 20504 KiB | ||||
31 | Accepted | 115ms | 20428 KiB | ||||
32 | Accepted | 114ms | 20608 KiB | ||||
33 | Accepted | 115ms | 20812 KiB | ||||
34 | Accepted | 115ms | 20764 KiB | ||||
35 | Accepted | 115ms | 20864 KiB | ||||
36 | Wrong answer | 114ms | 22024 KiB | ||||
37 | Wrong answer | 114ms | 22220 KiB |