Submission #558573

#TimeUsernameProblemLanguageResultExecution timeMemory
558573JomnoiGondola (IOI14_gondola)C++17
20 / 100
27 ms4540 KiB
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;

int valid(int n, int inputSeq[]) {
    set <int> s;
    int pos = -1;
    for(int i = 0; i < n; i++) {
        if(inputSeq[i] <= n) {
            pos = i;
            s.insert(inputSeq[i]);
        }
    }
    
    if(s.size() < n) {
        return 0;
    }
    if(pos == -1) {
        return 1;
    }

    int start = (inputSeq[pos] - pos - 1 + 2 * n) % n + 1;
    for(int i = 0; i < n; i++) {
        if(inputSeq[i] <= n and inputSeq[i] != (start + i - 1) % n + 1) {
            return 0;
        }
    }
    return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
    return -2;
}

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

int countReplacement(int n, int inputSeq[]) {
    if(valid(n, inputSeq) == 0) {
        return 0;
    }
    
    // otherwise

    return -3;
}

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:15:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     if(s.size() < n) {
      |        ~~~~~~~~~^~~
#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...