제출 #1111929

#제출 시각아이디문제언어결과실행 시간메모리
1111929fryingducA Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #ifdef duc_debug #include "bits/debug.h" #else #include "books.h" #define debug(...) #endif const int maxn = 1e5 + 5; int n, k, q; long long m; long long a[maxn]; long long ans[maxn]; int cnt_asks; long long ask(int id) { if(a[id]) return a[id]; ++cnt_asks; if(cnt_asks > q) { assert(0); exit(0); } #ifdef duc_debug return a[id] = ans[id]; #else a[id] = skim(id); return a[id] = x; #endif } void solve(int N, int K, long long A, int S) { n = N, k = K, m = A, q = S; long long sum = 0; for(int i = 1; i <= k; ++i) { sum += ask(i); } if(sum > 2 * m) { impossible(); return; } sum -= a[k]; int l = k, r = n; int res = -1; while(l <= r) { int mid = (l + r) >> 1; if(sum + ask(mid) >= m) { res = mid; r = mid - 1; } else { l = mid + 1; } } if(res != -1) { if(a[res] + sum <= 2 * m) { vector<int> ds; for(int i = 1; i < k; ++i) ds.push_back(i); ds.push_back(res); answer(ds); return; } } else { res = n + 1; } sum += a[--res]; set<int> s; for(int i = 1; i < k; ++i) s.insert(i); s.insert(res); for(int i = res - 1, j = k - 1; i > 0 and j > 0; --i, --j) { if(sum >= m) break; sum -= ask(j); s.erase(j); s.insert(i); sum += ask(i); } if(sum < m || sum > m * 2) { impossible(); return; } vector<int> ds; for(auto i:s) ds.push_back(i); answer(ds); }

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

books.cpp: In function 'long long int ask(int)':
books.cpp:31:20: error: 'x' was not declared in this scope
   31 |     return a[id] = x;
      |                    ^