Submission #985377

# Submission time Handle Problem Language Result Execution time Memory
985377 2024-05-17T17:09:22 Z user736482 Cave (IOI13_cave) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
bool result[5000],fixed_[5000];
int match[5000],openstate,ak;
void change(int a, int b, bool c){
    for(int i=a;i<=b;i++){
        if(!fixed_[i])
            result[i]= c;
    }
}

void exploreCave(int n){
    for(int i=0;i<n;i++){
        int pocz=0;
        int kon=n-1;
        change(pocz,kon,1);
        ak=tryCombination(result);
        if(ak==i)
            openstate=0;
        else
            openstate=1;
        while(pocz<kon){
            int sr=(pocz+kon)/2;
            change(pocz,sr,openstate);
            change(sr+1,kon,!openstate);
            ak=tryCombination(result);
            if(ak==i)
                pocz=sr+1;
            else
                kon=sr;
        }
        result[pocz]=openstate;
        match[i]=pocz;
        fixed_[pocz]=1;
    }
    answer(result,match);
}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:18:27: error: cannot convert 'bool*' to 'int*'
   18 |         ak=tryCombination(result);
      |                           ^~~~~~
      |                           |
      |                           bool*
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:27:31: error: cannot convert 'bool*' to 'int*'
   27 |             ak=tryCombination(result);
      |                               ^~~~~~
      |                               |
      |                               bool*
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:37:12: error: cannot convert 'bool*' to 'int*'
   37 |     answer(result,match);
      |            ^~~~~~
      |            |
      |            bool*
In file included from cave.cpp:2:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~