107552024-04-11 12:47:49CWMMexxcpp17Accepted 100/100252ms16776 KiB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

void output_vector(vector<int> vec, bool isEnterSeperated) {
    for (size_t i = 0; i < vec.size(); i++)
    {
        cout << vec[i];
        if (isEnterSeperated) {
            cout << "\n";
        }
        else {
            cout << " ";
        }
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> res(n,-1);
    vector<int> inp(n);
    vector<bool> app(2*n);
    int old = -1;
    for (size_t i = 0; i < n; i++)
    {
        cin >> inp[i];
        if (inp[i] > i + 1 || inp[i]<old) {
            cout << "NEM";
            return 0;
        }
        app[inp[i]] = true;
        if (inp[i] != old) {
            res[i] = old;
        }
        old = inp[i];
    }
    int l = 0;
    for (size_t i = 0; i < res.size(); i++)
    {
        if (res[i] == -1) {
            for (size_t j = l; j < app.size(); j++)
            {
                if (!app[j]) {
                    l = j;
                    break;
                }
            }
            res[i] = l;
            l++;
        }
    }
    cout << "IGEN\n";
    output_vector(res, false);
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2060 KiB
subtask28/8
3Accepted2ms2136 KiB
4Accepted3ms2392 KiB
5Accepted3ms2456 KiB
6Accepted3ms2636 KiB
7Accepted2ms2744 KiB
8Accepted2ms2812 KiB
9Accepted3ms2952 KiB
10Accepted2ms3040 KiB
11Accepted2ms3036 KiB
subtask316/16
12Accepted2ms3036 KiB
13Accepted2ms3060 KiB
14Accepted2ms3036 KiB
15Accepted2ms3036 KiB
16Accepted3ms3160 KiB
subtask432/32
17Accepted4ms3328 KiB
18Accepted6ms3592 KiB
19Accepted4ms3620 KiB
20Accepted4ms3540 KiB
21Accepted4ms3540 KiB
22Accepted6ms3804 KiB
23Accepted4ms4004 KiB
24Accepted4ms4208 KiB
subtask544/44
25Accepted245ms16320 KiB
26Accepted248ms16200 KiB
27Accepted246ms16196 KiB
28Accepted246ms16252 KiB
29Accepted246ms16232 KiB
30Accepted248ms16232 KiB
31Accepted247ms16472 KiB
32Accepted247ms16476 KiB
33Accepted247ms16532 KiB
34Accepted247ms16544 KiB
35Accepted252ms16776 KiB
36Accepted143ms12688 KiB
37Accepted149ms12704 KiB