Submission #649440

#TimeUsernameProblemLanguageResultExecution timeMemory
649440cadmiumskyA Difficult(y) Choice (BOI21_books)C++14
45 / 100
2 ms340 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; using ll = long long; const int nmax = 1e5 + 5; namespace QUERY { ll v[nmax]; set<int> ind; ll query(int x) { if(v[x] == 0) { v[x] = skim(x); ind.insert(x); } return v[x]; } } ll n, k, a, s; ll fmin(ll x) { return x * k + k * (k - 1) / 2; } ll fmax(ll x) { return x * k - k * (k - 1) / 2; } using namespace QUERY; #define list shsflkhsdsdhsd vector<ll> list; vector<int> sol; void mksolve(int lp, ll sum = 0) { if(sum > 2 * a) return; if(sol.size() == k) { if(sum >= a) { answer(sol); } return; } lp++; for(int i = lp; i + k - sol.size() <= list.size(); i++) { sol.push_back(list[i]); sum += v[list[i]]; mksolve(i, sum); sol.pop_back(); sum -= v[list[i]]; } return; } void solve(int _N, int _K, long long _A, int _S) { n = _N; k = _K; a = _A; s = _S; s = min(40LL, s); int l = 0; for(int i = 16; i >= 0; i--) { if(l + (1 << i) >= n) continue; if(fmin(query(l + (1 << i))) < a) l += (1 << i); s--; } //cerr << l << ' ' << s << '\n'; if(l == n) impossible(); l++; s = min(s, 25LL); if(query(l) >= a) { list.push_back(l); for(int i = 1; i <= n && s > 0; s--, i++) query(i), list.push_back(i); } else { int lim = (s + 1) / 2; //cerr << lim << ' ' << s << '\n'; for(int i = l; i > 0 && lim > 0; s--, i--, lim--) list.push_back(i), query(i); for(int i = max(1, l); s > 0 && i <= n; i++, s--) list.push_back(i), query(i); } sort(list.begin(), list.end()); list.resize(unique(list.begin(), list.end()) - list.begin()); //for(auto x : list) cerr << x << ' '; //cerr << '\n'; sol.reserve(40); mksolve(-1); impossible(); }

Compilation message (stderr)

books.cpp: In function 'void mksolve(int, ll)':
books.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   36 |   if(sol.size() == k) {
      |      ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...