6117 | 2023-11-01 18:49:41 | horvathabel | Mexx | cpp17 | Accepted 100/100 | 252ms | 24768 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 (x>i+1 || a[i]<a[i-1]){
cout<<"NEM\n";
return 0;
}
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<<" ";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1684 KiB | ||||
2 | Accepted | 3ms | 1940 KiB | ||||
subtask2 | 8/8 | ||||||
3 | Accepted | 3ms | 2168 KiB | ||||
4 | Accepted | 3ms | 2356 KiB | ||||
5 | Accepted | 3ms | 2600 KiB | ||||
6 | Accepted | 3ms | 2816 KiB | ||||
7 | Accepted | 3ms | 2944 KiB | ||||
8 | Accepted | 2ms | 3160 KiB | ||||
9 | Accepted | 3ms | 3328 KiB | ||||
10 | Accepted | 3ms | 3548 KiB | ||||
11 | Accepted | 3ms | 3632 KiB | ||||
subtask3 | 16/16 | ||||||
12 | Accepted | 3ms | 3752 KiB | ||||
13 | Accepted | 2ms | 3840 KiB | ||||
14 | Accepted | 2ms | 3956 KiB | ||||
15 | Accepted | 2ms | 3844 KiB | ||||
16 | Accepted | 3ms | 3960 KiB | ||||
subtask4 | 32/32 | ||||||
17 | Accepted | 4ms | 4232 KiB | ||||
18 | Accepted | 4ms | 4236 KiB | ||||
19 | Accepted | 4ms | 4232 KiB | ||||
20 | Accepted | 6ms | 4356 KiB | ||||
21 | Accepted | 4ms | 4440 KiB | ||||
22 | Accepted | 4ms | 4444 KiB | ||||
23 | Accepted | 4ms | 4428 KiB | ||||
24 | Accepted | 4ms | 4548 KiB | ||||
subtask5 | 44/44 | ||||||
25 | Accepted | 246ms | 23896 KiB | ||||
26 | Accepted | 250ms | 23908 KiB | ||||
27 | Accepted | 246ms | 23900 KiB | ||||
28 | Accepted | 245ms | 23924 KiB | ||||
29 | Accepted | 246ms | 24016 KiB | ||||
30 | Accepted | 248ms | 24068 KiB | ||||
31 | Accepted | 246ms | 24184 KiB | ||||
32 | Accepted | 248ms | 24352 KiB | ||||
33 | Accepted | 246ms | 24540 KiB | ||||
34 | Accepted | 246ms | 24768 KiB | ||||
35 | Accepted | 252ms | 24724 KiB | ||||
36 | Accepted | 143ms | 22172 KiB | ||||
37 | Accepted | 150ms | 22556 KiB |