Submission #548995

#TimeUsernameProblemLanguageResultExecution timeMemory
548995Leo121Cave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "cave.h"

#define forn(i, a, b) for(int i = int(a); i <= int(b); ++ i)

using namespace std;

vector<int> nores;

void inicializar(int &arre[], const int &n, int &posiciones[], int &estado[]){
    forn(i, 0, n){
        arre[i] = (posiciones[i] == -1) ? 0 : estado[i];
        if(posiciones[i] == -1){
            nores.push_back(i);
        }
    }
}

void actualizar(int li, int ls, int mitad, int &arre[]){
    forn(i, li, ls){
        arre[nores[i]] = (i <= mitad) ? 1 : 0;
    }
}

void bs(int pos, const int &n, int &posiciones[], int &estado[]){
    int li = 0, ls = n - pos - 1, mitad;
    int prueba[n + 1];
    nores.clear();
    inicializar(prueba, n, posiciones, estado);
    int aux = tryCombination(prueba);
    if(!ls){
        posiciones[pos] = nores[ls];
        estado[pos] = (aux == -1) ? 0 : 1;
        return;
    }
    bool saber = (aux == pos);
    while(li < ls){
        mitad = (li + ls) / 2;
        actualizar(li, ls, mitad, prueba);
        aux = tryCombination(prueba);
        if((saber && aux == pos) || (!saber && aux != pos)){
            li = mitad + 1;
        }
        else{
            ls = mitad;
        }
    }
    posiciones[pos] = nores[li];
    estado[pos] = (int) saber;
}

void exploreCave(int N) {
    int posiciones[N];
    int estado[N];
    forn(i, 0, N - 1){
        posiciones[i] = -1;
        estado[i] = 0;
    }
    forn(i, 0, N - 1){
        bs(i, N, posiciones, estado);
    }
    answer(estado, posiciones);
}

Compilation message (stderr)

cave.cpp:10:23: error: declaration of 'arre' as array of references
   10 | void inicializar(int &arre[], const int &n, int &posiciones[], int &estado[]){
      |                       ^~~~
cave.cpp:10:29: error: expected ')' before ',' token
   10 | void inicializar(int &arre[], const int &n, int &posiciones[], int &estado[]){
      |                 ~           ^
      |                             )
cave.cpp:10:31: error: expected unqualified-id before 'const'
   10 | void inicializar(int &arre[], const int &n, int &posiciones[], int &estado[]){
      |                               ^~~~~
cave.cpp:19:49: error: declaration of 'arre' as array of references
   19 | void actualizar(int li, int ls, int mitad, int &arre[]){
      |                                                 ^~~~
cave.cpp: In function 'void actualizar(...)':
cave.cpp:20:13: error: 'li' was not declared in this scope; did you mean 'i'?
   20 |     forn(i, li, ls){
      |             ^~
cave.cpp:4:39: note: in definition of macro 'forn'
    4 | #define forn(i, a, b) for(int i = int(a); i <= int(b); ++ i)
      |                                       ^
cave.cpp:20:17: error: 'ls' was not declared in this scope
   20 |     forn(i, li, ls){
      |                 ^~
cave.cpp:4:52: note: in definition of macro 'forn'
    4 | #define forn(i, a, b) for(int i = int(a); i <= int(b); ++ i)
      |                                                    ^
cave.cpp:21:9: error: 'arre' was not declared in this scope
   21 |         arre[nores[i]] = (i <= mitad) ? 1 : 0;
      |         ^~~~
cave.cpp:21:32: error: 'mitad' was not declared in this scope
   21 |         arre[nores[i]] = (i <= mitad) ? 1 : 0;
      |                                ^~~~~
cave.cpp: At global scope:
cave.cpp:25:37: error: declaration of 'posiciones' as array of references
   25 | void bs(int pos, const int &n, int &posiciones[], int &estado[]){
      |                                     ^~~~~~~~~~
cave.cpp:25:49: error: expected ')' before ',' token
   25 | void bs(int pos, const int &n, int &posiciones[], int &estado[]){
      |        ~                                        ^
      |                                                 )
cave.cpp:25:51: error: expected unqualified-id before 'int'
   25 | void bs(int pos, const int &n, int &posiciones[], int &estado[]){
      |                                                   ^~~