73122024-01-06 21:02:58anonMexxcpp17Partially correct 0/100115ms22220 KiB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
    FastIO;
    bool ok, same;
    ll i, j, rs, N;
    cin >> N;
    vector<ll> lucky(N);
    for(i = 0; i < N; i++)
        cin >> lucky[i];
    rs = -1;
    ok = same = true;
    vector<ll> ans(N, 0);
    stack<ll> free_places;
    for(i = 1; i < N; i++) {
        if(lucky[i] == lucky[i - 1])
            continue;
        same = false;
        for(j = 0; j < min(lucky[i] - lucky[i - 1], i - rs); j++)
            ans[i - j] = j + lucky[i - 1];
        while(j < i - rs)
            free_places.push(i - j++);
        while(j < lucky[i] - lucky[i - 1]) {
            if(free_places.empty())
                goto done;
            ans[free_places.top()] = j++ + lucky[i - 1];
            free_places.pop();
        }
        rs = i;
    }
    if(same) {
        switch(lucky[0]) {
            case 0:
                ok = true;
                fill(all(ans), 1);
                break;
            case 1:
                ok = true;
                break;
            default:
                ok = false;
        }
    }
    done:;
    if(ok) {
        cout << "IGEN\n";
        for(const auto &x : ans)
            cout << x << ' ';
        cout << '\n';
    }
    else
        cout << "NEM\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1824 KiB
2Accepted3ms2028 KiB
subtask20/8
3Accepted3ms2236 KiB
4Partially correct2ms2320 KiB
5Accepted3ms2444 KiB
6Partially correct3ms2652 KiB
7Accepted2ms2892 KiB
8Accepted3ms2864 KiB
9Accepted3ms3076 KiB
10Accepted3ms3296 KiB
11Wrong answer3ms3516 KiB
subtask30/16
12Accepted3ms3736 KiB
13Accepted3ms3660 KiB
14Accepted3ms3652 KiB
15Wrong answer3ms3756 KiB
16Wrong answer3ms3652 KiB
subtask40/32
17Accepted4ms4032 KiB
18Accepted4ms4256 KiB
19Accepted4ms4184 KiB
20Accepted4ms4348 KiB
21Accepted4ms4424 KiB
22Accepted4ms4432 KiB
23Wrong answer4ms4440 KiB
24Wrong answer4ms4452 KiB
subtask50/44
25Accepted115ms20328 KiB
26Accepted115ms20204 KiB
27Accepted114ms20484 KiB
28Accepted115ms20444 KiB
29Accepted115ms20448 KiB
30Accepted115ms20504 KiB
31Accepted115ms20428 KiB
32Accepted114ms20608 KiB
33Accepted115ms20812 KiB
34Accepted115ms20764 KiB
35Accepted115ms20864 KiB
36Wrong answer114ms22024 KiB
37Wrong answer114ms22220 KiB