Submission #229325

# Submission time Handle Problem Language Result Execution time Memory
229325 2020-05-04T08:25:53 Z osaaateiasavtnl Gondola (IOI14_gondola) C++14
Compilation error
0 ms 0 KB
#include "gondola.h"

int valid(int n, int a[])
{
    set <int> ms;
    for (int i = 0; i < n; ++i)
        ms.insert(a[i]);
    if (ms.size() < n)
        return 0;

    int pos = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= n) {
            pos = i;
            break;
        }
    }   

    if (pos == -1)
        return 1;
    else {
        for (int sh = 0; sh < n; ++sh) {
            int i = (pos + sh) % n;
            int val = a[pos] + sh;
            if (val > n)
                val -= n;
            if (a[i] <= n && a[i] != val)
                return 0;
        }
        return 1;
    }   

}

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

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

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

int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:5:5: error: 'set' was not declared in this scope
     set <int> ms;
     ^~~
gondola.cpp:5:10: error: expected primary-expression before 'int'
     set <int> ms;
          ^~~
gondola.cpp:7:9: error: 'ms' was not declared in this scope
         ms.insert(a[i]);
         ^~
gondola.cpp:8:9: error: 'ms' was not declared in this scope
     if (ms.size() < n)
         ^~