9652022-02-06 12:34:06nmarciTitkos sorozatcpp11Wrong answer 0/4054ms11568 KiB
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <list>
using namespace std;
using ll = long long int;

ll inf = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> ans(n);
    int ctr = n;
    for(int i = 0; i < n; ++i){
        cin >> v[i];
        if(v[i] == -1){
            ans[i] = ctr--;
        }
    }
    int i = n - 1;
    while(i >= 0){
        if(v[i] != -1){
            int ptr = i;
            while(ptr >= 0 && v[ptr] == v[i]){
                --ptr;
            }
            if(v[ptr] != v[i]) ++ptr;
            while(ptr <= i){
                ans[ptr] = ctr--;
                ++ptr;
            }
        }
        --i;
    }
    for(auto i : ans)
        cout << i << " ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Accepted0/02ms1740 KiB
2Wrong answer0/021ms2776 KiB
3Wrong answer0/11ms2132 KiB
4Wrong answer0/11ms2132 KiB
5Wrong answer0/21ms2140 KiB
6Wrong answer0/11ms2152 KiB
7Wrong answer0/11ms2152 KiB
8Wrong answer0/22ms2156 KiB
9Wrong answer0/241ms4048 KiB
10Wrong answer0/243ms4624 KiB
11Wrong answer0/241ms5200 KiB
12Wrong answer0/241ms5776 KiB
13Wrong answer0/241ms6460 KiB
14Wrong answer0/241ms7080 KiB
15Wrong answer0/241ms7600 KiB
16Wrong answer0/341ms8044 KiB
17Wrong answer0/337ms8316 KiB
18Wrong answer0/339ms8872 KiB
19Wrong answer0/354ms9460 KiB
20Wrong answer0/343ms10044 KiB
21Wrong answer0/141ms10568 KiB
22Wrong answer0/139ms11072 KiB
23Wrong answer0/139ms11568 KiB