Submission #1113755

#TimeUsernameProblemLanguageResultExecution timeMemory
1113755vladiliusCave (IOI13_cave)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second

void exploreCave(int n){
    vector<int> b(n), p(n), s(n), ch;
    for (int i = 0; i < n; i++) ch.pb(i);
    for (int i = 0; i < n; i++){
        fill(s.begin(), s.end(), 0);
        for (int j = 0; j < i; j++){
            s[p[j]] = b[j];
        }
        int f = tryCombination(s), d = (f == i);
        b[i] = d;
        int l = 0, r = (int) ch.size() - 1;
        
        auto check = [&](int m){
            for (int j = 0; j <= m; j++){
                s[ch[j]] = d;
            }
            for (int j = m + 1; j < ch.size(); j++){
                s[ch[j]] = !d;
            }
            int f = tryCombination(s);
            return (f != i);
        };
        
        while (l + 1 < r){
            int m = (l + r) / 2;
            if (check(m)){
                r = m;
            }
            else {
                l = m + 1;
            }
        }
        if (check(l)) r = l;

        p[i] = ch[r];
        ch.erase(ch.begin() + r);
    }
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++){
        x[p[i]] = i;
        y[p[i]] = b[i];
    }
    
    answer(y, x);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:17:17: error: 'tryCombination' was not declared in this scope
   17 |         int f = tryCombination(s), d = (f == i);
      |                 ^~~~~~~~~~~~~~
cave.cpp:18:16: error: 'd' was not declared in this scope
   18 |         b[i] = d;
      |                ^
cave.cpp: In lambda function:
cave.cpp:25:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for (int j = m + 1; j < ch.size(); j++){
      |                                 ~~^~~~~~~~~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:17:13: warning: unused variable 'f' [-Wunused-variable]
   17 |         int f = tryCombination(s), d = (f == i);
      |             ^
cave.cpp:52:5: error: 'answer' was not declared in this scope
   52 |     answer(y, x);
      |     ^~~~~~