105122024-04-04 11:18:37RRoliMexxcpp17Partially correct 19/100108ms13500 KiB
#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 = 1; 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms2176 KiB
2Partially correct3ms2336 KiB
subtask20/8
3Accepted3ms2652 KiB
4Accepted3ms2800 KiB
5Partially correct3ms2884 KiB
6Accepted3ms3064 KiB
7Wrong answer2ms3144 KiB
8Partially correct3ms3320 KiB
9Accepted2ms3276 KiB
10Partially correct2ms3280 KiB
11Accepted3ms3352 KiB
subtask30/16
12Partially correct3ms3160 KiB
13Partially correct3ms3288 KiB
14Partially correct3ms3632 KiB
15Wrong answer3ms3840 KiB
16Accepted3ms3952 KiB
subtask48/32
17Partially correct4ms4148 KiB
18Partially correct4ms4004 KiB
19Partially correct4ms4136 KiB
20Partially correct4ms4252 KiB
21Partially correct4ms4260 KiB
22Partially correct4ms4248 KiB
23Accepted3ms4120 KiB
24Accepted3ms4092 KiB
subtask511/44
25Accepted103ms12776 KiB
26Partially correct104ms13072 KiB
27Partially correct104ms13092 KiB
28Partially correct104ms13212 KiB
29Partially correct104ms13408 KiB
30Partially correct105ms13500 KiB
31Partially correct104ms13304 KiB
32Partially correct104ms13212 KiB
33Partially correct107ms13268 KiB
34Partially correct105ms13348 KiB
35Partially correct108ms13160 KiB
36Accepted61ms12556 KiB
37Accepted63ms12532 KiB