104902024-04-03 12:14:14csaron71Mexxcpp17Accepted 100/100254ms17864 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> szamok;
    vector<int> valt;
    bool vege=false;
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        szamok.push_back(x);
        if (szamok[i]>i+1) {
            vege=true;
        }
    }
    if (vege==true) {
        cout << "NEM\n";
        return 0;
    }
    for (int i=1; i<n; i++) {
        if (szamok[i]<szamok[i-1]) {
            cout << "NEM\n";
            return 0;
        }
        if (szamok[i]>szamok[i-1]) {
            valt.push_back(szamok[i]);
        }
    }

    int epp=0;
    vector<int> veg;
    int y=0;
    if (szamok[0]==0) {
        epp++;
        while (valt.size()>y && epp==valt[y]) {
            epp++;
            y++;
        }
        veg.push_back(epp);
    }
    else  {
        veg.push_back(epp);
        epp++;
    }
    for (int i=1; i<n; i++) {
        if (szamok[i]>szamok[i-1]) {
             veg.push_back(szamok[i-1]);
        }
        else {
            epp++;
            while (valt.size()>y && epp==valt[y]) {
                epp++;
                y++;
            }
            veg.push_back(epp);
        }
    }
    cout << "IGEN\n";
    for (int sz : veg) {
        cout << sz << " ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2060 KiB
subtask28/8
3Accepted3ms2296 KiB
4Accepted3ms2784 KiB
5Accepted3ms2588 KiB
6Accepted3ms2640 KiB
7Accepted3ms2824 KiB
8Accepted3ms2964 KiB
9Accepted3ms3176 KiB
10Accepted3ms3268 KiB
11Accepted3ms3388 KiB
subtask316/16
12Accepted3ms3488 KiB
13Accepted3ms3600 KiB
14Accepted3ms3852 KiB
15Accepted3ms3920 KiB
16Accepted3ms4068 KiB
subtask432/32
17Accepted6ms4436 KiB
18Accepted6ms4612 KiB
19Accepted4ms4568 KiB
20Accepted4ms4568 KiB
21Accepted6ms4824 KiB
22Accepted6ms4780 KiB
23Accepted4ms4736 KiB
24Accepted4ms4928 KiB
subtask544/44
25Accepted246ms14788 KiB
26Accepted247ms14824 KiB
27Accepted246ms14744 KiB
28Accepted247ms14844 KiB
29Accepted248ms17032 KiB
30Accepted246ms16948 KiB
31Accepted246ms17012 KiB
32Accepted247ms17016 KiB
33Accepted250ms17020 KiB
34Accepted250ms17336 KiB
35Accepted254ms17864 KiB
36Accepted181ms9040 KiB
37Accepted179ms9092 KiB