Submission #772786

#TimeUsernameProblemLanguageResultExecution timeMemory
772786ZHIRDILBILDIZA Difficult(y) Choice (BOI21_books)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> //#include"books.h" #define ll long long #define fi first #define se second using namespace std ; //void impossible() //{ // cout << "-1\n" ; // exit(0) ; //} //void answer(vector<int> ans) //{ // for(int i : ans) // cout << i << ' ' ; // exit(0) ; //} //ll skim(int ind) //{ // cout << "? " << ind << '\n' ; // return ind ; //} void solve(int n, int k, ll a, int s) { vector<int> ans ; ll x[n + 1] = {}, pref[n + 1] = {} ; for(int i = 1 ; i <= k ; i++) { x[i] = skim(i) ; pref[i] = pref[i - 1] + x[i] ; } if(pref[k] > 2ll * a) impossible() ; if(a <= pref[k] && pref[k] <= 2ll * a) { for(int i = 1 ; i <= k ; i++) ans.push_back(i) ; answer(ans) ; } if(s >= n) { for(int i = k + 1 ; i <= n ; i++) { x[i] = skim(i) ; pref[i] = pref[i - 1] + x[i] ; } for(int i = 1 ; i <= n ; i++) if(x[i] >= a && pref[k - 1] + x[i] <= 2ll * a) { for(int j = 1 ; j < k ; j++) ans.push_back(j) ; ans.push_back(i) ; answer(ans) ; } for(int i = k ; i <= n ; i++) if(a <= pref[i] - pref[i - k] && pref[i] - pref[i - k] <= 2ll * a) { for(int j = i - k + 1 ; j <= i ; j++) ans.push_back(j) ; answer(ans) ; } impossible() ; } ll l = 0, r = n + 1 ; while(l + 1 < r) { int mid = (l + r) >> 1 ; ll num = x[mid] ; if(!num) { num = skim(mid) ; x[mid] = num ; } if(num < a)l = mid ; else r = mid ; } if(r != n + 1 && x[r] + pref[k - 1] <= 2ll * a) { for(int i = 1 ; i < k ; i++) ans.push_back(i) ; ans.push_back(r) ; answer(ans) ; } l = 0, r = n - k + 1 ; vector<pair<ll, int>> w, ls ; while(l + 1 < r) { w.clear() ; ll mid = (l + r) >> 1, sum = 0 ; for(int i = mid ; i < mid + k ; i++) { ll num = x[i] ; if(!num)num = skim(i) ; sum += num ; w.push_back({num, i}) ; } if(sum > 2 * a)r = mid ; else { ls = w ; ans.clear() ; for(auto i : w) ans.push_back(i.se) ; l = mid ; } } ll sum = 0 ; for(auto i : ls) sum += i.fi ; if(a <= sum && sum <= 2 * a) answer(ans) ; else impossible() ; } //signed main() //{ // int n, k, a, s ; // cin >> n >> k >> a >> s ; // solve(n, k, a, s) ; // return 0 ; //}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:29:16: error: 'skim' was not declared in this scope
   29 |         x[i] = skim(i) ;
      |                ^~~~
books.cpp:33:9: error: 'impossible' was not declared in this scope
   33 |         impossible() ;
      |         ^~~~~~~~~~
books.cpp:38:9: error: 'answer' was not declared in this scope
   38 |         answer(ans) ;
      |         ^~~~~~
books.cpp:44:20: error: 'skim' was not declared in this scope
   44 |             x[i] = skim(i) ;
      |                    ^~~~
books.cpp:53:17: error: 'answer' was not declared in this scope
   53 |                 answer(ans) ;
      |                 ^~~~~~
books.cpp:60:17: error: 'answer' was not declared in this scope
   60 |                 answer(ans) ;
      |                 ^~~~~~
books.cpp:62:9: error: 'impossible' was not declared in this scope
   62 |         impossible() ;
      |         ^~~~~~~~~~
books.cpp:71:19: error: 'skim' was not declared in this scope
   71 |             num = skim(mid) ;
      |                   ^~~~
books.cpp:82:9: error: 'answer' was not declared in this scope
   82 |         answer(ans) ;
      |         ^~~~~~
books.cpp:93:27: error: 'skim' was not declared in this scope
   93 |             if(!num)num = skim(i) ;
      |                           ^~~~
books.cpp:111:9: error: 'answer' was not declared in this scope
  111 |         answer(ans) ;
      |         ^~~~~~
books.cpp:113:9: error: 'impossible' was not declared in this scope
  113 |         impossible() ;
      |         ^~~~~~~~~~