Submission #1316193

#TimeUsernameProblemLanguageResultExecution timeMemory
1316193pablo7948Cave (IOI13_cave)C++20
Compilation error
0 ms0 KiB
#include <vector> #include "cave.h" #include <unordered_set> using namespace std; void negate(vector<int>& comb, const unordered_set<int>& known, int L, int R) { for(int i = L; i < R; i++) { if(known.count(i) == 0) { comb[i] = 1 - comb[i]; } } } void exploreCave(int N) { vector<int> comb(N, 0); int current = 0; vector<int> inter(N, -1); vector<int> pos(N, -1); unordered_set<int> known; known.reserve(N); int res = tryCombination(comb); bool prev = res != 0; while(current < N) { int L = 0, R = N - 1; while(L != R) { int mid = (L+R)/2 + 1; negate(comb, known); res = tryCombination(comb.data()); bool open = res >= N || res == -1; if(open != prev) { R = mid - 1; } else { L = mid; } prev = open; } inter[current] = L; if(!prev) comb[current] = 1 - comb[current]; pos[current] = comb[current]; prev = res >= N + 1 || res == -1; known.insert(L); } answer(inter.data(), pos.data()); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:49:30: error: cannot convert 'std::vector<int>' to 'int*'
   49 |     int res = tryCombination(comb);
      |                              ^~~~
      |                              |
      |                              std::vector<int>
In file included from cave.cpp:3:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:65:13: error: reference to 'negate' is ambiguous
   65 |             negate(comb, known);
      |             ^~~~~~
In file included from /usr/include/c++/13/bits/refwrap.h:39,
                 from /usr/include/c++/13/vector:68,
                 from cave.cpp:1:
/usr/include/c++/13/bits/stl_function.h:175:12: note: candidates are: 'template<class _Tp> struct std::negate'
  175 |     struct negate;
      |            ^~~~~~
cave.cpp:13:6: note:                 'void negate(std::vector<int>&, const std::unordered_set<int>&, int, int)'
   13 | void negate(vector<int>& comb, const unordered_set<int>& known, int L, int R) {
      |      ^~~~~~