제출 #546225

#제출 시각아이디문제언어결과실행 시간메모리
546225LunaMeme동굴 (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef vector<pair<int, int>> vii; typedef vector<int> vi; typedef long long ll; #define PB push_back #define MP make_pair #define FOR(i, x, y) for (int i = x; i < y ; i ++) /*int N; vi S, D, C; void answer(vi A, vi B) { for(int i = 0; i < N; i ++) cout << A[i] << ' '; cout << '\n'; for(int i = 0; i < N; i ++) cout << B[i] << ' '; } int tryCombination(vi A) { for(int door = 0; door < N;door ++) { if(A[C[door]] != S[C[door]]) return door; } return -1; }*/ int opp(int d){ if (d == 1)return 0; return 1; } void exploreCave(int N) { vi arr(N, -1); vi ans(N); FOR(i, 0, N){ //door vi temp(N); FOR(k, 0, N){ if (arr[k] == -1)temp[k] = 0; else temp[k] = arr[k]; } int j = tryCombination(temp); int d = 0; //d is colour of i th switch if (j <= i && j > -1){ d = 1; } //binary search FOR(k, 0, N){ if (arr[k] == -1)temp[k] = d; else temp[k] = arr[k]; } int l = 0, r = N - 1; while(l < r){ int m = (l + r) / 2; FOR(k, l, m + 1){ if (arr[k] == -1) temp[k] = opp(d); else temp[k] = arr[k]; } FOR(k, 0, N){ cout << temp[k] << ' '; } cout << '\n'; j = tryCombination(temp); if (j > i || j == -1) //passes { l = m + 1; } else{ r = m; } FOR(k, 0, N){ if (arr[k] == -1)temp[k] = d; else temp[k] = arr[k]; } } assert(l == r); //cout << "Door " << i << " connects to switch " << l << '\n'; //assert(arr[l] == -1); arr[l] = d; ans[l] = i; } answer(arr, ans); } /*int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N; S.assign(N,0); D.assign(N,0); C.assign(N,0); for(int i = 0; i < N; i ++) cin >> S[i]; for(int i = 0; i < N; i ++) cin >> D[i]; for(int i = 0; i < N; i ++) C[D[i]] = i; exploreCave(N); } */

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:45:32: error: cannot convert 'vi' {aka 'std::vector<int>'} to 'int*'
   45 |         int j = tryCombination(temp);
      |                                ^~~~
      |                                |
      |                                vi {aka 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:67:32: error: cannot convert 'vi' {aka 'std::vector<int>'} to 'int*'
   67 |             j = tryCombination(temp);
      |                                ^~~~
      |                                |
      |                                vi {aka 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:87:12: error: cannot convert 'vi' {aka 'std::vector<int>'} to 'int*'
   87 |     answer(arr, ans);
      |            ^~~
      |            |
      |            vi {aka 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[]);
      |             ~~~~^~~