제출 #1316192

#제출 시각아이디문제언어결과실행 시간메모리
1316192pablo7948동굴 (IOI13_cave)C++20
컴파일 에러
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); 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, pos); }

컴파일 시 표준 에러 (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) {
      |      ^~~~~~
cave.cpp:67:34: error: cannot convert 'std::vector<int>' to 'int*'
   67 |             res = tryCombination(comb);
      |                                  ^~~~
      |                                  |
      |                                  std::vector<int>
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:101:12: error: cannot convert 'std::vector<int>' to 'int*'
  101 |     answer(inter, pos);
      |            ^~~~~
      |            |
      |            std::vector<int>
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~