Submission #680865

#TimeUsernameProblemLanguageResultExecution timeMemory
680865YENGOYANA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // void solve(int n, int k, long long a, int s) { // TODO implement this function vector<ll> vec(n); ll sm = 0; for (int i = 0; i < k - 1; ++i) vec[i] = skim(i + 1), sm += vec[i]; int l = k - 2, r = n - 1; while (l + 1 < r) { int m = (l + r) / 2; ll b = skim(m + 1); vec[m] = b; if (sm + b >= a) r = m; else l = m; } if (sm + vec[r] > 2 * a || sm + vec[r] < a) { impossible(); return; } vector<int> ans; for (int i = 1; i <= k - 1; ++i) ans.push_back(i); ans.push_back(r + 1); answer(ans); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:18:12: error: 'll' was not declared in this scope
   18 |     vector<ll> vec(n);
      |            ^~
books.cpp:18:14: error: template argument 1 is invalid
   18 |     vector<ll> vec(n);
      |              ^
books.cpp:18:14: error: template argument 2 is invalid
books.cpp:19:7: error: expected ';' before 'sm'
   19 |     ll sm = 0;
      |       ^~~
      |       ;
books.cpp:20:40: error: invalid types 'int[int]' for array subscript
   20 |     for (int i = 0; i < k - 1; ++i) vec[i] = skim(i + 1), sm += vec[i];
      |                                        ^
books.cpp:20:59: error: 'sm' was not declared in this scope; did you mean 's'?
   20 |     for (int i = 0; i < k - 1; ++i) vec[i] = skim(i + 1), sm += vec[i];
      |                                                           ^~
      |                                                           s
books.cpp:20:68: error: invalid types 'int[int]' for array subscript
   20 |     for (int i = 0; i < k - 1; ++i) vec[i] = skim(i + 1), sm += vec[i];
      |                                                                    ^
books.cpp:24:11: error: expected ';' before 'b'
   24 |         ll b = skim(m + 1);
      |           ^~
      |           ;
books.cpp:25:12: error: invalid types 'int[int]' for array subscript
   25 |         vec[m] = b;
      |            ^
books.cpp:25:18: error: 'b' was not declared in this scope
   25 |         vec[m] = b;
      |                  ^
books.cpp:26:13: error: 'sm' was not declared in this scope; did you mean 'm'?
   26 |         if (sm + b >= a) r = m;
      |             ^~
      |             m
books.cpp:29:9: error: 'sm' was not declared in this scope; did you mean 's'?
   29 |     if (sm + vec[r] > 2 * a || sm + vec[r] < a) {
      |         ^~
      |         s
books.cpp:29:17: error: invalid types 'int[int]' for array subscript
   29 |     if (sm + vec[r] > 2 * a || sm + vec[r] < a) {
      |                 ^
books.cpp:29:40: error: invalid types 'int[int]' for array subscript
   29 |     if (sm + vec[r] > 2 * a || sm + vec[r] < a) {
      |                                        ^