제출 #1310735

#제출 시각아이디문제언어결과실행 시간메모리
1310735theiulius동굴 (IOI13_cave)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #include "cave.h" void exploreCave(int N) { int n = N; vector<int> used(n, 0); // which switches already fixed (mp in your code) vector<int> a(n, 0), b(n, -1); for (int i = 0; i < n; ++i) { // set all unfixed switches to 0 and query to determine berk for (int j = 0; j < n; ++j) if (!used[j]) a[j] = 0; int x = tryCombination(a); int berk = (x > i || x == -1) ? 0 : 1; // build list of unused switches (indices) vector<int> unused; unused.reserve(n); for (int j = 0; j < n; ++j) if (!used[j]) unused.push_back(j); // binary search on positions inside `unused` int L = 0, R = (int)unused.size() - 1; int pos = -1; while (L <= R) { int mid = (L + R) >> 1; // set first mid+1 unused switches to berk, rest to 1^berk for (int k = 0; k <= mid; ++k) a[unused[k]] = berk; for (int k = mid + 1; k < (int)unused.size(); ++k) a[unused[k]] = (1 ^ berk); x = tryCombination(a); if (x > i || x == -1) { pos = mid; // possible answer in unused[pos] R = mid - 1; } else { L = mid + 1; } } // pos must be valid; but just in case (defensive), handle -1 if (pos == -1) pos = (int)unused.size() - 1; int ans = unused[pos]; b[ans] = i; used[ans] = 1; a[ans] = berk; // fix this switch permanently } answer(a.data(), b.data()); }

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

cave.cpp: In function 'void exploreCave(long long int)':
cave.cpp:14:32: error: cannot convert 'std::vector<long long int>' to 'long long int*'
   14 |         int x = tryCombination(a);
      |                                ^
      |                                |
      |                                std::vector<long long int>
In file included from cave.cpp:4:
cave.h:8:24: note:   initializing argument 1 of 'long long int tryCombination(long long int*)'
    8 | int tryCombination(int S[]);
cave.cpp:32:32: error: cannot convert 'std::vector<long long int>' to 'long long int*'
   32 |             x = tryCombination(a);
      |                                ^
      |                                |
      |                                std::vector<long long int>
cave.h:8:24: note:   initializing argument 1 of 'long long int tryCombination(long long int*)'
    8 | int tryCombination(int S[]);