54092023-05-13 10:34:03TomaSajtMexxcpp17Accepted 100/100104ms12380 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0), ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &ai : a) cin >> ai;
  vector<int> b(n, -1);
  vector<bool> used(n + 1);

  for (int i = 0; i < n; i++) {
    int ap = i == 0 ? 0 : a[i - 1];
    if (ap > a[i] || a[i] > i + 1) {
      cout << "NEM";
      return 0;
    }
    if (ap < a[i]) {
      b[i] = a[i - 1];
      used[b[i]] = true;
    }
  }
  used[a[n - 1]] = true;  // don't use last value
  int val = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] != -1) continue;
    while (used[val]) val++;
    b[i] = val;
    used[val] = true;
  }
  cout << "IGEN\n";
  for (int &bi : b) cout << bi << ' ';
  return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1692 KiB
2Accepted3ms1872 KiB
subtask28/8
3Accepted3ms1872 KiB
4Accepted3ms2080 KiB
5Accepted2ms2164 KiB
6Accepted3ms2292 KiB
7Accepted2ms2376 KiB
8Accepted3ms2780 KiB
9Accepted3ms2636 KiB
10Accepted2ms2632 KiB
11Accepted2ms2524 KiB
12Accepted3ms2652 KiB
subtask316/16
13Accepted3ms2652 KiB
14Accepted3ms2856 KiB
15Accepted3ms3060 KiB
16Accepted2ms3148 KiB
17Accepted3ms3276 KiB
18Accepted3ms3504 KiB
subtask432/32
19Accepted3ms3504 KiB
20Accepted4ms3908 KiB
21Accepted4ms3904 KiB
22Accepted4ms4028 KiB
23Accepted4ms4248 KiB
24Accepted4ms4200 KiB
25Accepted4ms4464 KiB
26Accepted3ms4408 KiB
27Accepted3ms4456 KiB
subtask544/44
28Accepted3ms4456 KiB
29Accepted101ms12216 KiB
30Accepted101ms12380 KiB
31Accepted101ms12352 KiB
32Accepted101ms12088 KiB
33Accepted101ms12092 KiB
34Accepted101ms12036 KiB
35Accepted103ms12044 KiB
36Accepted101ms12096 KiB
37Accepted104ms12096 KiB
38Accepted103ms12216 KiB
39Accepted104ms12208 KiB
40Accepted56ms12148 KiB
41Accepted57ms12064 KiB