제출 #248935

#제출 시각아이디문제언어결과실행 시간메모리
248935Dilshod_Imomov동굴 (IOI13_cave)C++17
컴파일 에러
0 ms0 KiB
# include <bits/stdc++.h> # include "cave.h" using namespace std; const int MAX_N = 5007; pair < int, int > sw[MAX_N], door[MAX_N]; int n, counts; /* void input() { cin >> n; for ( int i = 0; i < n; i++ ) { int x, y; cin >> x >> y; // switch i connects door x when on y sw[i] = {x, y}; door[x] = { i, y }; } } int tryCombination(vector < int > S ) { counts++; for ( int i = 0; i < n; i++ ) { if ( S[door[i].first] == door[i].second ) { continue; } return i; } return -1; } void answer( vector < int > S, vector < int > D ) { for ( int i = 0; i < n; i++ ) { int dr = D[i], t = S[i]; cout << S[i] << ' ' << D[i] << '\n'; if ( door[dr].first != i || door[dr].second != t ) { // cout << "Wrong Answer" << '\n'; // exit(0); } } cout << "Accepted with " << counts << " counts.\n"; exit(0); } */ vector < int > create( vector < int > vc ) { for ( int i = 0; i < (int)vc.size(); i++ ) { if ( vc[i] == -1 ) { vc[i] = 1; } } return vc; } int can( vector < int > doors, int mid, int l, int r ) { int cnt = mid, cntl = 0; for ( int i = 0; i < n; i++ ) { if ( doors[i] != -1 ) { continue; } if ( cntl < l ) { doors[i] = 1; cntl++; continue; } if ( cnt ) { doors[i] = 0; cnt--; } else { doors[i] = 1; } } for ( int i = 0; i < n; i++ ) { cout << doors[i] << ' '; } cout << '\n'; return tryCombination(doors); } int find( vector < int > doors, int l ) { int cnt = 0; for ( int i = 0; i < n; i++ ) { if ( doors[i] != -1 ) { continue; } if ( cnt == l ) { return i; } cnt++; } return 0; } void exploreCave(int N) { n = N; vector < int > doors(N, -1), S(N), D(N); int cnt = N - 1; for ( int i = 0; i < N; i++ ) { int fdoor = tryCombination( create(doors) ); int ans = 0; if ( fdoor != i ) { ans = 1; } int l = 0, r = cnt, mid; cout << i <<'\n'; while ( l < r ) { mid = (l + r) / 2; int x = can( doors, mid - l + 1, l, r ); cout << l << ' ' << mid << " " << r << ' ' << ans << ' ' << x << '\n'; if ( x != i ) { if ( ans == 0 ) { r = mid; } else { l = mid + 1; } } else { if ( ans == 0 ) { l = mid + 1; } else { r = mid; } } } int x = find(doors, l); doors[x] = ans; S[x] = ans; D[x] = i; cout << x << ' ' << ans << '\n'; cnt--; } answer(S, D); } /* int main() { input(); exploreCave(n); return 0; } */

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

cave.cpp: In function 'int can(std::vector<int>, int, int, int)':
cave.cpp:76:29: error: cannot convert 'std::vector<int>' to 'int*' for argument '1' to 'int tryCombination(int*)'
  return tryCombination(doors);
                             ^
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:98:45: error: cannot convert 'std::vector<int>' to 'int*' for argument '1' to 'int tryCombination(int*)'
   int fdoor = tryCombination( create(doors) );
                                             ^
cave.cpp:133:13: error: cannot convert 'std::vector<int>' to 'int*' for argument '1' to 'void answer(int*, int*)'
  answer(S, D);
             ^