Submission #807549

#TimeUsernameProblemLanguageResultExecution timeMemory
807549dong_liuA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; void solve(int n, int k, long long A, int s) { vector<long long> a(n, -1); auto qry = [&](int i) { if (~a[i]) return a[i]; return a[i] = skim(i + 1); }; int low = k, hi = n; while (low < hi) { int mid = (low + hi) / 2; if (qry(mid) >= A) hi = mid; else low = mid + 1; } if (low < n) { __int128 sum = qry(low); for (int i = 0; i < k - 1; i++) sum += qry(i); if (sum >= A && sum <= A * 2) { vector<int> inds(k); iota(inds.begin(), inds.end(), 1); inds.back() = low + 1; answer(inds); return; } } vector<int> pos; low--; for (int i = 0; i < k; i++) { pos.push_back(i); if (low - i >= 0) pos.push_back(low - i); } sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin(), pos.end()), pos.end()); for (int i = 0; i < (int)pos.size() - k + 1; i++) { __int128 sum = 0; for (int j = i; j < i + k; j++) sum += qry(pos[j]); if (sum >= A && sum <= A * 2) { vector<int> inds(k); for (int u = 0; u < k; u++) inds[u] = pos[i + u] + 1; answer(inds); return; } } impossible(); }

Compilation message (stderr)

books.cpp: In lambda function:
books.cpp:9:19: error: 'skim' was not declared in this scope
    9 |     return a[i] = skim(i + 1);
      |                   ^~~~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:26:7: error: 'answer' was not declared in this scope
   26 |       answer(inds);
      |       ^~~~~~
books.cpp:44:7: error: 'answer' was not declared in this scope
   44 |       answer(inds);
      |       ^~~~~~
books.cpp:48:3: error: 'impossible' was not declared in this scope
   48 |   impossible();
      |   ^~~~~~~~~~