Submission #787758

#TimeUsernameProblemLanguageResultExecution timeMemory
787758fabijan_cikacA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pp pair<int, ll> #define F first #define S second #define ll long long #define pb push_back void solve(int N, int K, ll A, int S){ int l = 1, r = N; while (l < r){ int mid = (l + r - 1) / 2; if (skim(mid) >= A) r = mid; else l = mid + 1; } vector<pp> v; for (int i = 1; i <= min(K, l - K); ++i) v.pb({i, skim(i)}); for (int i = max(K + 1, l - K + 1); i <= l; ++i) v.pb({i, skim(i)}); for (int i = 0; i < (1 << (int)(v.size())); ++i){ if (__builtin_popcount(i) != k) continue; ll sum = 0; for (int j = 0; j < v.size(); ++j){ if (i & (1 << j)) sum += v[j].S; } if (sum >= A && sum <= 2 * A){ vector<int> ans; for (int j = 0; j < v.size(); ++j){ if (i & (1 << j)) ans.pb(v[j].F); } sort(ans.begin(), ans.end()); answer(ans); } } impossible(); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); return 0; }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:15:13: error: 'skim' was not declared in this scope
   15 |         if (skim(mid) >= A)
      |             ^~~~
books.cpp:21:18: error: 'skim' was not declared in this scope
   21 |         v.pb({i, skim(i)});
      |                  ^~~~
books.cpp:21:26: error: no matching function for call to 'std::vector<std::pair<int, long long int> >::push_back(<brace-enclosed initializer list>)'
   21 |         v.pb({i, skim(i)});
      |                          ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long long int>; _Alloc = std::allocator<std::pair<int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, long long int>; _Alloc = std::allocator<std::pair<int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long long int> >::value_type&&' {aka 'std::pair<int, long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
books.cpp:23:18: error: 'skim' was not declared in this scope
   23 |         v.pb({i, skim(i)});
      |                  ^~~~
books.cpp:23:26: error: no matching function for call to 'std::vector<std::pair<int, long long int> >::push_back(<brace-enclosed initializer list>)'
   23 |         v.pb({i, skim(i)});
      |                          ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long long int>; _Alloc = std::allocator<std::pair<int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, long long int>; _Alloc = std::allocator<std::pair<int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long long int> >::value_type&&' {aka 'std::pair<int, long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
books.cpp:25:38: error: 'k' was not declared in this scope
   25 |         if (__builtin_popcount(i) != k)
      |                                      ^
books.cpp:28:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int j = 0; j < v.size(); ++j){
      |                         ~~^~~~~~~~~~
books.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             for (int j = 0; j < v.size(); ++j){
      |                             ~~^~~~~~~~~~
books.cpp:36:43: error: 'answer' was not declared in this scope
   36 |             sort(ans.begin(), ans.end()); answer(ans);
      |                                           ^~~~~~
books.cpp:39:5: error: 'impossible' was not declared in this scope
   39 |     impossible();
      |     ^~~~~~~~~~