61162023-11-01 18:45:21horvathabelMexxcpp17Wrong answer 0/100252ms24084 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> ans(n,-1);
    vector<pair<bool,int>> szm={{0,0}};
    int x;
    cin>>x;
    vector<int> a={x};
    bool mego=true;
    for (int i=1; i<n;i++){
        szm.push_back({false,i});
        int x;
        cin>>x;
        a.push_back(x);
        if (a[i]!=a[i-1]){
            ans[i]=a[i-1];
            if (szm.size()>=a[i-1]){
                szm[a[i-1]].first=true;
            }
            else{
                mego=false;
            }
        }
    }

    szm.push_back({false,n});
    szm[a[n-1]].first=true;
    if (!mego){
        cout<<"NEM\n";
        return 0;
    }
    if (a[0]>1){
        cout<<"NEM\n";
        return 0;
    }
    for (int i=n-1;i>=0;i--){
        if (ans[i]==-1){
            while(!szm.empty() && szm[szm.size()-1].first==1){
                szm.pop_back();
            }
            ans[i]=szm[szm.size()-1].second;
            szm.pop_back();
        }
    }
    cout<<"IGEN\n";
    for (int x:ans) cout<<x<<" ";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2064 KiB
subtask20/8
3Accepted3ms2368 KiB
4Accepted3ms2544 KiB
5Accepted3ms2728 KiB
6Accepted3ms3012 KiB
7Accepted3ms2892 KiB
8Accepted3ms3132 KiB
9Accepted2ms3168 KiB
10Accepted3ms3288 KiB
11Wrong answer3ms3408 KiB
subtask30/16
12Accepted3ms3508 KiB
13Accepted3ms3624 KiB
14Accepted3ms3712 KiB
15Wrong answer2ms3660 KiB
16Wrong answer2ms3648 KiB
subtask40/32
17Accepted4ms3924 KiB
18Accepted6ms4056 KiB
19Accepted6ms4268 KiB
20Accepted6ms4404 KiB
21Accepted6ms4420 KiB
22Accepted6ms4524 KiB
23Wrong answer4ms4420 KiB
24Wrong answer4ms4504 KiB
subtask50/44
25Accepted246ms23980 KiB
26Accepted244ms24060 KiB
27Accepted245ms23932 KiB
28Accepted246ms23840 KiB
29Accepted246ms23868 KiB
30Accepted252ms24032 KiB
31Accepted250ms24084 KiB
32Accepted246ms24056 KiB
33Accepted246ms23864 KiB
34Accepted247ms23964 KiB
35Accepted247ms23964 KiB
36Wrong answer245ms23944 KiB
37Wrong answer244ms24036 KiB