Submission #687339

#TimeUsernameProblemLanguageResultExecution timeMemory
687339AlcabelA 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) { int l = -1, r = n; long long found = -1; while (r - l > 1) { int m = l + (r - l) / 2; long long cur = skim(m + 1); if (cur >= a) { found = cur; r = m; } else { l = m; } } vector<int> ans(k); iota(ans.begin(), ans.end(), 1); if (r + 1 <= k - 1) { impossible(); return; } vector<long long> first(k); long long sumFirst = 0; for (int i = 0; i < k; ++i) { first[i] = skim(i + 1); sumFirst += first[i]; } if (r != n && sumFirst - first.back() + found <= 2 * a) { ans.back() = r + 1; answer(ans); return; } n = r; vector<long long> last(k); long long sumLast = 0; for (int i = n - 1; i >= n - k; --i) { last[n - 1 - i] = skim(i + 1); sumLast += last[n - 1 - i]; } if (sumFirst >= a && sumFirst <= 2 * a) { answer(ans); return; } if (sumLast >= a && sumLast <= 2 * a) { iota(ans.begin(), ans.end(), n - k + 1); answer(ans); return; } if (sumFirst > 2 * a || sumLast < a) { impossible(); return; } long long sum = sumFirst; iota(ans.begin(), ans.end(), 1); for (int i = k - 1; sum < a; --i) { assert(i >= 0); sum -= first[i]; sum += last[k - 1 - i]; ans[i] = n - (k - 1 - i); } answer(ans); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:9:25: error: 'skim' was not declared in this scope
    9 |         long long cur = skim(m + 1);
      |                         ^~~~
books.cpp:20:9: error: 'impossible' was not declared in this scope
   20 |         impossible();
      |         ^~~~~~~~~~
books.cpp:26:20: error: 'skim' was not declared in this scope
   26 |         first[i] = skim(i + 1);
      |                    ^~~~
books.cpp:31:9: error: 'answer' was not declared in this scope
   31 |         answer(ans);
      |         ^~~~~~
books.cpp:38:27: error: 'skim' was not declared in this scope
   38 |         last[n - 1 - i] = skim(i + 1);
      |                           ^~~~
books.cpp:42:9: error: 'answer' was not declared in this scope
   42 |         answer(ans);
      |         ^~~~~~
books.cpp:47:9: error: 'answer' was not declared in this scope
   47 |         answer(ans);
      |         ^~~~~~
books.cpp:51:9: error: 'impossible' was not declared in this scope
   51 |         impossible();
      |         ^~~~~~~~~~
books.cpp:62:5: error: 'answer' was not declared in this scope
   62 |     answer(ans);
      |     ^~~~~~