Submission #301339

# Submission time Handle Problem Language Result Execution time Memory
301339 2020-09-17T21:02:18 Z peti1234 Cave (IOI13_cave) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
const int c=5002;
int par[c];
bool v[c], t[c];
int f(int a, int b) {
    for (int i=a; i<b; i++) if (!v[i]) t[i]=1-t[i];
}
bool jo(int p) {
    int x=tryCombination(t);
    if (x==-1) x=1e9;
    return x>p;
}
void exploreCave(int n) {
    for (int i=0; i<n; i++) {
        if (!jo(i)) f(0, n);
        int lo=0, hi=n;
        while(hi-lo>1) {
            int mid=(hi+lo)/2;
            f(mid, hi);
            if (jo(i)) hi=mid;
            else lo=mid, f(mid, hi);
        }
        par[lo]=i, v[lo]=1;
    }
    answer(t, par);
}

Compilation message

cave.cpp: In function 'int f(int, int)':
cave.cpp:9:1: warning: no return statement in function returning non-void [-Wreturn-type]
    9 | }
      | ^
cave.cpp: In function 'bool jo(int)':
cave.cpp:11:26: error: cannot convert 'bool*' to 'int*'
   11 |     int x=tryCombination(t);
      |                          ^
      |                          |
      |                          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: In function 'void exploreCave(int)':
cave.cpp:27:12: error: cannot convert 'bool*' to 'int*'
   27 |     answer(t, par);
      |            ^
      |            |
      |            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[]);
      |             ~~~~^~~