Submission #399542

#TimeUsernameProblemLanguageResultExecution timeMemory
399542TemmieA 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, ll a, int s) { std::vector <ll> vals(n + 1, -1), use; vals[n] = skim(n); if (vals[n] * ll(k) < a) { impossible(); return; } int l = k, r = n; while (l < r) { int mid = (l + r) >> 1; if (vals[mid] == -1LL) vals[mid] = skim(mid); if (ll(k) * vals[mid] >= a) r = mid; else l = mid + 1; } std::vector <int> res; ll sum = 0; for (int i = 1 + l - k; i < l + 1; i++) { if (vals[i] == -1LL) vals[i] = skim(i); res.push_back(i); use.push_back(vals[i]); } for (ll x : use) sum += x; if (a <= sum) { if (sum <= a + a) answer(res); else impossible(); return; } for (int i = l + 1; i < 1 + l + k; i++) { if (vals[i] == -1LL) vals[i] = skim(i); sum += vals[i]; sum -= use[i - l - 1]; res.push_back(i); if (a <= sum && sum <= a + a) { std::vector <int> ans; for (int j = i - l; j < (int)res.size(); j++) { ans.push_back(res[j]); } answer(ans); return; } else if (sum > a + a) { ll newsum = vals[i]; std::vector <int> ans = { i }; for (int j = 1; j < k; j++) { ans.push_back(j); if (vals[j] == -1LL) vals[j] = skim(j); newsum += vals[j]; } if (newsum >= a && newsum <= a + a) { std::sort(ans.begin(), ans.end()); // ??? answer(ans); return; } impossible(); return; } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:9:12: error: 'skim' was not declared in this scope
    9 |  vals[n] = skim(n);
      |            ^~~~
books.cpp:11:3: error: 'impossible' was not declared in this scope
   11 |   impossible();
      |   ^~~~~~~~~~
books.cpp:30:21: error: 'answer' was not declared in this scope
   30 |   if (sum <= a + a) answer(res);
      |                     ^~~~~~
books.cpp:31:8: error: 'impossible' was not declared in this scope
   31 |   else impossible();
      |        ^~~~~~~~~~
books.cpp:44:4: error: 'answer' was not declared in this scope
   44 |    answer(ans);
      |    ^~~~~~
books.cpp:56:5: error: 'answer' was not declared in this scope
   56 |     answer(ans);
      |     ^~~~~~
books.cpp:59:4: error: 'impossible' was not declared in this scope
   59 |    impossible();
      |    ^~~~~~~~~~
books.cpp:63:2: error: 'impossible' was not declared in this scope
   63 |  impossible();
      |  ^~~~~~~~~~