Submission #1259323

#TimeUsernameProblemLanguageResultExecution timeMemory
1259323sokratisiCave (IOI13_cave)C++20
Compilation error
0 ms0 KiB
#include "cave.h"
#include <vector>
#include <set>

using namespace std;

set<int> use;
vector<int> s, d; // correct positions, door

pair<int, int> bsearch(int i) {
    vector<int> t;
    for (auto u: use) t.push_back(u);

    int cntrl = tryCombination(t);
    int sv;

    int l = 0, r = t.size()-1;
    while(l < r) {
        int m = (l + r) / 2;
        vector<int> ts = s;
        for (int i = l; i <= m; i++) {
            ts[t[i]] = 1-ts[t[i]];
            int ans = tryCombination(ts);
            sv = ans;
            if (cntrl == i && ans > i) r = m;
            else if (cntrl > i && ans == i) r = m;
            else l = m + 1;
        }
    }
    // the switch is t[l]
    int corpos;
    if (cntrl > i) corpos = s[t[l]];
    else corpos = 1 - s[t[l]]; 
    return {t[l], corpos};
}

void exploreCave(int n) {
    s.resize(n);
    d.resize(n);
    for (int i = 0; i < n; i++) use.insert(i);
    for (int i = 0; i < n; i++) {
        pair<int, int> ans = bsearch(i);
        use.erase(ans.first);
        s[ans.first] = ans.second;
        d[ans.first] = i;
    }
}

Compilation message (stderr)

cave.cpp: In function 'std::pair<int, int> bsearch(int)':
cave.cpp:14:32: error: cannot convert 'std::vector<int>' to 'int*'
   14 |     int cntrl = tryCombination(t);
      |                                ^
      |                                |
      |                                std::vector<int>
In file included from cave.cpp:1:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:23:38: error: cannot convert 'std::vector<int>' to 'int*'
   23 |             int ans = tryCombination(ts);
      |                                      ^~
      |                                      |
      |                                      std::vector<int>
In file included from cave.cpp:1:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~