72822024-01-05 22:00:19anonTitkos sorozatcpp17Accepted 40/4025ms7040 KiB
#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
    FastIO;
    ll i, j, v, lo, hi, N;
    cin >> N;
    vector<ll> B(N);
    for(i = 0; i < N; i++)
        cin >> B[i];
    lo = 0;
    hi = N + 1;
    vector<ll> todo(N, -1);
    for(i = 0; i < N; i++) {
        if(todo[i] != -1)
            lo = todo[i];
        if(B[i] == -1)
            cout << --hi << ' ';
        else {
            j = B[i] - 1;
            v = lo + j - i;
            if(todo[j] == -1)
                todo[j] = v;
            cout << v << ' ';
        }
    }
    cout << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms2008 KiB
2Accepted0/014ms3720 KiB
3Accepted1/13ms2280 KiB
4Accepted1/13ms2448 KiB
5Accepted2/23ms2532 KiB
6Accepted1/13ms2556 KiB
7Accepted1/13ms2828 KiB
8Accepted2/23ms2752 KiB
9Accepted2/224ms5716 KiB
10Accepted2/224ms5724 KiB
11Accepted2/224ms5924 KiB
12Accepted2/224ms6136 KiB
13Accepted2/225ms6276 KiB
14Accepted2/224ms6376 KiB
15Accepted2/224ms6616 KiB
16Accepted3/324ms6616 KiB
17Accepted3/324ms6936 KiB
18Accepted3/324ms6904 KiB
19Accepted3/324ms6796 KiB
20Accepted3/324ms6996 KiB
21Accepted1/124ms7040 KiB
22Accepted1/124ms7036 KiB
23Accepted1/124ms7000 KiB