Submission #582239

#TimeUsernameProblemLanguageResultExecution timeMemory
582239kamelfanger83Gondola (IOI14_gondola)C++14
25 / 100
12 ms668 KiB
#include <iostream>
#include <vector>
#include "gondola.h"
#include <limits>
#include <numeric>
#include <algorithm>

using namespace std;

int valid(int n, int inputSeq[]){
    int one = numeric_limits<int>::min();
    vector<bool> used (250001, false);
    for(int c = 0; c < n; c++){
        if(inputSeq[c] <= n){
            if(one == numeric_limits<int>::min()) one = c - inputSeq[c] + 1;
            if((c - one + 1) % n != inputSeq[c] % n) return 0; 
        }
        else{
            if(used[inputSeq[c]]) return 0;
            used[inputSeq[c]] = true;
        }
    }
    return 1;
}

int replacement(int n, int gondolaSeq[], int replacementSeq[]){
    int one = 0;
    for(int c = 0; c < n; c++){
        if(gondolaSeq[c] <= n) one = c - gondolaSeq[c] + 1;
    }

    vector<int> ind (n); iota(ind.begin(), ind.end(), 0);
    auto gcomp = [&](int u, int v){return gondolaSeq[u] < gondolaSeq[v];};
    sort(ind.begin(), ind.end(), gcomp);

    int repg = n;
    int l = 0;
    for(int rep : ind){
        while(repg < gondolaSeq[rep]){
            int num = (rep - one + 1 + n) % n;
            if(num == 0) num = n;
            replacementSeq[l++] = num;
            repg++;
        }
    }
    return l;
}

int countReplacement(int n, int inputSeq[]){

}

Compilation message (stderr)

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:51:1: warning: no return statement in function returning non-void [-Wreturn-type]
   51 | }
      | ^
#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...