105132024-04-04 11:24:36RRoliMexxcpp17Wrong answer 76/100108ms13492 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 = 0; 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
1Accepted3ms1900 KiB
2Accepted3ms2244 KiB
subtask20/8
3Accepted3ms2452 KiB
4Accepted3ms2660 KiB
5Accepted3ms3000 KiB
6Accepted3ms2956 KiB
7Wrong answer3ms3108 KiB
8Accepted3ms3304 KiB
9Accepted3ms3264 KiB
10Accepted3ms3392 KiB
11Accepted3ms3544 KiB
subtask30/16
12Accepted3ms3616 KiB
13Accepted3ms3688 KiB
14Accepted3ms3568 KiB
15Wrong answer3ms3644 KiB
16Accepted3ms3976 KiB
subtask432/32
17Accepted4ms4188 KiB
18Accepted4ms4396 KiB
19Accepted4ms4488 KiB
20Accepted4ms4468 KiB
21Accepted4ms4504 KiB
22Accepted4ms4492 KiB
23Accepted3ms4260 KiB
24Accepted3ms4528 KiB
subtask544/44
25Accepted105ms13124 KiB
26Accepted104ms13332 KiB
27Accepted104ms13284 KiB
28Accepted104ms13276 KiB
29Accepted105ms13356 KiB
30Accepted104ms13392 KiB
31Accepted104ms13492 KiB
32Accepted107ms13276 KiB
33Accepted107ms13356 KiB
34Accepted108ms13404 KiB
35Accepted108ms13356 KiB
36Accepted63ms12640 KiB
37Accepted63ms12596 KiB