54032023-05-12 16:55:21szilMexxcpp14Accepted 100/100101ms13188 KiB
#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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted4ms5832 KiB
2Accepted4ms6152 KiB
subtask28/8
3Accepted4ms6152 KiB
4Accepted4ms6240 KiB
5Accepted4ms6192 KiB
6Accepted4ms6528 KiB
7Accepted4ms6716 KiB
8Accepted4ms6884 KiB
9Accepted4ms6836 KiB
10Accepted4ms7100 KiB
11Accepted4ms7012 KiB
12Accepted4ms7016 KiB
subtask316/16
13Accepted4ms7016 KiB
14Accepted4ms7004 KiB
15Accepted4ms7016 KiB
16Accepted4ms7312 KiB
17Accepted4ms7268 KiB
18Accepted4ms7220 KiB
subtask432/32
19Accepted4ms7220 KiB
20Accepted4ms7372 KiB
21Accepted4ms7516 KiB
22Accepted4ms7616 KiB
23Accepted4ms7760 KiB
24Accepted6ms7800 KiB
25Accepted4ms7812 KiB
26Accepted4ms7760 KiB
27Accepted4ms7748 KiB
subtask544/44
28Accepted4ms7748 KiB
29Accepted98ms12092 KiB
30Accepted97ms12076 KiB
31Accepted98ms11972 KiB
32Accepted98ms12076 KiB
33Accepted98ms12056 KiB
34Accepted98ms12076 KiB
35Accepted98ms11936 KiB
36Accepted100ms12048 KiB
37Accepted98ms12116 KiB
38Accepted100ms12116 KiB
39Accepted101ms12068 KiB
40Accepted57ms13188 KiB
41Accepted56ms11804 KiB