Submission #424245

#TimeUsernameProblemLanguageResultExecution timeMemory
424245Harry464A Difficult(y) Choice (BOI21_books)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> using namespace std; typedef long long ll; void solve(int N, int K, long long A, int S){ vector <ll> srch(N+1. -1); ll suma = 0; for (int i = 1; i <= min(N,K); i++){ srch[i] = skim(i); suma += srch[i]; } if (suma > 2*A) impossible(); vector <int> odg; if (suma >= A && suma <= 2*A){ for (i = 1; i <= K; i++) odg.push_back(i); answer(odg); } ll l = 1, r = N + 1; while (l < r){ ll mid = (l+r)/2; srch[mid] = skim(mid); if (srch[mid] >= A) r = mid; else l = mid + 1; } for (int i = min(N,l); i >= max(0, l - K); i--){ if (srch[i] == -1) srch[i] = skim(i); } if (l > K && l <= N){ ll nsuma = suma - srch[K] + srch[l]; if (nsuma >= A && nsuma <= 2*A){ for (int i = 1; i <= K -1; i++) odg.push_back(i); odg.push_back(l); answer(odg); } } vector <bool> uklj(N + 1, false); for (int i = 1; i <= K; i++) uklj[i] = true; for (int i = 1; i <= min(K, l - K - 1); i++){ suma -= srch[i]; suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false; if (suma >= A && suma <= 2*A){ for (int i = 1; i <= N; i++) if (uklj[i]) odg.push_back(i); answer(odg); } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:19:15: error: 'skim' was not declared in this scope
   19 |     srch[i] = skim(i);
      |               ^~~~
books.cpp:25:5: error: 'impossible' was not declared in this scope
   25 |     impossible();
      |     ^~~~~~~~~~
books.cpp:31:11: error: 'i' was not declared in this scope
   31 |      for (i = 1; i <= K; i++)
      |           ^
books.cpp:34:6: error: 'answer' was not declared in this scope
   34 |      answer(odg);
      |      ^~~~~~
books.cpp:43:17: error: 'skim' was not declared in this scope
   43 |     srch[mid] = skim(mid);
      |                 ^~~~
books.cpp:52:23: error: no matching function for call to 'min(int&, ll&)'
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
books.cpp:52:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
books.cpp:52:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
books.cpp:52:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
books.cpp:52:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                       ^
books.cpp:52:43: error: no matching function for call to 'max(int, ll)'
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
books.cpp:52:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
books.cpp:52:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
books.cpp:52:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
books.cpp:52:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   52 |   for (int i = min(N,l); i >= max(0, l - K); i--){
      |                                           ^
books.cpp:55:17: error: 'skim' was not declared in this scope
   55 |       srch[i] = skim(i);
      |                 ^~~~
books.cpp:69:9: error: 'answer' was not declared in this scope
   69 |         answer(odg);
      |         ^~~~~~
books.cpp:79:40: error: no matching function for call to 'min(int&, ll)'
   79 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
books.cpp:79:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   79 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
books.cpp:79:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   79 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
books.cpp:79:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   79 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
books.cpp:79:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   79 |   for (int i = 1; i <= min(K, l - K - 1); i++){
      |                                        ^
books.cpp:82:34: error: no matching function for call to 'max(int, ll)'
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
books.cpp:82:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
books.cpp:82:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
books.cpp:82:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
books.cpp:82:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                  ^
books.cpp:82:59: error: no matching function for call to 'max(int, ll)'
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
books.cpp:82:59: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
books.cpp:82:59: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
books.cpp:82:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from books.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
books.cpp:82:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |     suma += srch[max(K+i, l-K+i-1)], uklj[max(K+i, l-K+i-1)] = true, uklj[i] = false;
      |                                                           ^
books.cpp:90:9: error: 'answer' was not declared in this scope
   90 |         answer(odg);
      |         ^~~~~~
books.cpp:96:3: error: 'impossible' was not declared in this scope
   96 |   impossible();
      |   ^~~~~~~~~~