Submission #444216

#TimeUsernameProblemLanguageResultExecution timeMemory
444216FEDIKUSGondola (IOI14_gondola)C++17
25 / 100
16 ms696 KiB
#include "gondola.h"

#include<bits/stdc++.h>

using namespace std;

const int maxn=2.5e5+10;
bool imam[maxn];

int valid(int n, int inputSeq[]){
    int tren=-1;
    for(int i=0;i<n;i++){
        if(imam[inputSeq[i]]) return 0;
        imam[inputSeq[i]]=true;
        if(inputSeq[i]>n){
            if(tren!=-1) tren++;
            if(tren>n) tren=1;
            continue;
        }
        if(tren==-1) tren=inputSeq[i];
        else{
            if(inputSeq[i]!=tren) return 0;
        }
        tren++;
        if(tren>n) tren=1;
    }
    return 1;
}

//----------------------

int treba[maxn];

int replacement(int n, int gondolaSeq[], int replacementSeq[]){
    int l=0;
    int tren=-1;
    int maxi=INT_MIN;
    for(int i=0;i<n;i++) maxi=max(maxi,gondolaSeq[i]);
    int gde=-1;
    for(int j=0;j<2*n;j++){
        int i=j%n;
        if(gondolaSeq[i]>n){
            if(tren!=-1){
                if(gondolaSeq[i]==maxi) gde=tren;
                treba[gondolaSeq[i]]=tren;
                tren++;
                if(tren>n) tren=1;
            }
            continue;
        }
        if(tren==-1) tren=gondolaSeq[i];
        tren++;
        if(tren>n) tren=1;
    }
    for(int i=n+1;i<=maxi;i++){
        if(treba[i]!=0){
            replacementSeq[l++]=treba[i];
        }else{
            replacementSeq[l++]=gde;
            gde=i;
        }
    }
    return l;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
/*
6
50
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 51 47 48 49 50 1 2 3
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...