Submission #399532

#TimeUsernameProblemLanguageResultExecution timeMemory
399532TemmieA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include "books.h" #include <bits/stdc++.h> typedef long long ll; void solve(int n, int k, int s, ll a) { std::vector <ll> vals(n + 1, -1); ll sumfirst = 0; for (int i = 1; i <= k - 1; i++) { vals[i] = ask(i); sumfirst += vals[i]; } int l = k + 1, r = n; int best = k; while (l <= r) { int mid = (l + r) >> 1; ll now = ask(mid); vals[mid] = now; ll total = now + sumfirst; if (total >= a + a) { r = mid - 1; } else { l = mid + 1; best = mid; } } if (best == k && sumfirst + vals[best] >= a + a) { impossible(); return; } if (sumfirst + vals[best] >= a) { std::vector <int> ans; for (int i = 1; i <= k - 1; i++) ans.push_back(i); ans.push_back(best); answer(ans); return; } std::vector <int> ans; for (int i = 1; i <= k - 1; i++) ans.push_back(i); ans.push_back(best); std::set <int> have; for (int x : ans) have.insert(x); ll sum = sumfirst + vals[best]; int cur = best; for (int i = 1 - 1; i <= k - 1 - 1; i++) { sum -= vals[ans[i]]; have.erase(ans[i]); int nw = --cur; if (have.count(nw)) { impossible(); return; } have.insert(nw); if (vals[nw] == -1LL) vals[nw] = ask(nw); sum += vals[nw]; if (sum >= a) break; } std::vector <int> put; for (int x : have) put.push_back(x); answer(put); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, int, ll)':
books.cpp:11:13: error: 'ask' was not declared in this scope
   11 |   vals[i] = ask(i);
      |             ^~~
books.cpp:18:12: error: 'ask' was not declared in this scope
   18 |   ll now = ask(mid);
      |            ^~~
books.cpp:55:36: error: 'ask' was not declared in this scope
   55 |   if (vals[nw] == -1LL) vals[nw] = ask(nw);
      |                                    ^~~