9662022-02-06 12:37:11nmarciTitkos sorozatcpp11Wrong answer 0/4063ms11884 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;
            int newi = ptr - 1;
            while(ptr <= i){
                ans[ptr] = ctr--;
                ++ptr;
            }
            i = newi;
        }
        else{
            --i;
        }
    }
    for(auto i : ans)
        cout << i << " ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Accepted0/02ms1736 KiB
2Wrong answer0/020ms2876 KiB
3Wrong answer0/11ms2120 KiB
4Wrong answer0/11ms2124 KiB
5Wrong answer0/21ms2132 KiB
6Wrong answer0/12ms2144 KiB
7Wrong answer0/11ms2148 KiB
8Wrong answer0/21ms2156 KiB
9Wrong answer0/243ms4036 KiB
10Wrong answer0/239ms4756 KiB
11Wrong answer0/243ms5192 KiB
12Wrong answer0/245ms5768 KiB
13Wrong answer0/239ms6348 KiB
14Wrong answer0/239ms6928 KiB
15Wrong answer0/241ms7504 KiB
16Wrong answer0/346ms8088 KiB
17Wrong answer0/363ms8796 KiB
18Wrong answer0/341ms9248 KiB
19Wrong answer0/361ms9828 KiB
20Wrong answer0/339ms10396 KiB
21Wrong answer0/139ms10972 KiB
22Wrong answer0/139ms11372 KiB
23Wrong answer0/141ms11884 KiB