제출 #550544

#제출 시각아이디문제언어결과실행 시간메모리
550544esomer동굴 (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std; void exploreCave(int N) { vector<int> correct(N, -1); vector<int> switches(N, -1); for(int i = 0; i < N; i++){ if(correct[i] == -1){ vector<int> v(N, 0); for(int j = 0; j < i; j++) v[j] = correct[j]; int x = tryCombination(v); if(x == -1){ for(int j = i; j < N; j++) correct[j] = 0; }else{ for(int j = i; j < x; j++) correct[j] = 0; correct[x] = 1; } } int lo = 0; int hi = N - 1; while(lo < hi){ int mid = (lo + hi) / 2; vector<int> v(N, 1 - correct[i]); for(int j = 0; j < i; j++){ v[switches[j]] = correct[j]; } for(int j = lo; j <= mid; j++) v[j] = correct[i]; int x = tryCombination(v); if(x > i || x == -1){ hi = mid; }else lo = mid + 1; } switches[i] = lo; } vector<int> d(N); for(int i = 0; i < N; i++){ d[switches[i]] = i; } vector<int> s(N); for(int i = 0; i < N; i++){ s[switches[i]] = correct[i]; } answer(s, d); }

컴파일 시 표준 에러 (stderr) 메시지

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:13:36: error: cannot convert 'std::vector<int>' to 'int*'
   13 |             int x = tryCombination(v);
      |                                    ^
      |                                    |
      |                                    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:30:36: error: cannot convert 'std::vector<int>' to 'int*'
   30 |             int x = tryCombination(v);
      |                                    ^
      |                                    |
      |                                    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:45:12: error: cannot convert 'std::vector<int>' to 'int*'
   45 |     answer(s, d);
      |            ^
      |            |
      |            std::vector<int>
In file included from cave.cpp:1:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~