제출 #687338

#제출 시각아이디문제언어결과실행 시간메모리
687338AlcabelA Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namspace std; void solve(int n, int k, long long a, int s) { int l = -1, r = n; long long found = -1; while (r - l > 1) { int m = l + (r - l) / 2; long long cur = skim(m + 1); if (cur >= a) { found = cur; r = m; } else { l = m; } } vector<int> ans(k); iota(ans.begin(), ans.end(), 1); if (r + 1 <= k - 1) { impossible(); return; } vector<long long> first(k); long long sumFirst = 0; for (int i = 0; i < k; ++i) { first[i] = skim(i + 1); sumFirst += first[i]; } if (r != n && sumFirst - first.back() + found <= 2 * a) { ans.back() = r + 1; answer(ans); return; } n = r; vector<long long> last(k); long long sumLast = 0; for (int i = n - 1; i >= n - k; --i) { last[n - 1 - i] = skim(i + 1); sumLast += last[n - 1 - i]; } if (sumFirst >= a && sumFirst <= 2 * a) { answer(ans); return; } if (sumLast >= a && sumLast <= 2 * a) { iota(ans.begin(), ans.end(), n - k + 1); answer(ans); return; } if (sumFirst > 2 * a || sumLast < a) { impossible(); return; } long long sum = sumFirst; iota(ans.begin(), ans.end(), 1); for (int i = k - 1; sum < a; --i) { assert(i >= 0); sum -= first[i]; sum += last[k - 1 - i]; ans[i] = n - (k - 1 - i); } answer(ans); }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp:2:7: error: expected nested-name-specifier before 'namspace'
    2 | using namspace std;
      |       ^~~~~~~~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:9:25: error: 'skim' was not declared in this scope
    9 |         long long cur = skim(m + 1);
      |                         ^~~~
books.cpp:17:5: error: 'vector' was not declared in this scope
   17 |     vector<int> ans(k);
      |     ^~~~~~
books.cpp:17:5: note: suggested alternatives:
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:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included 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/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
books.cpp:17:12: error: expected primary-expression before 'int'
   17 |     vector<int> ans(k);
      |            ^~~
books.cpp:18:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |     iota(ans.begin(), ans.end(), 1);
      |          ^~~
      |          abs
books.cpp:18:5: error: 'iota' was not declared in this scope; did you mean 'std::iota'?
   18 |     iota(ans.begin(), ans.end(), 1);
      |     ^~~~
      |     std::iota
In file included from /usr/include/c++/10/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_numeric.h:88:5: note: 'std::iota' declared here
   88 |     iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
      |     ^~~~
books.cpp:20:9: error: 'impossible' was not declared in this scope
   20 |         impossible();
      |         ^~~~~~~~~~
books.cpp:23:12: error: expected primary-expression before 'long'
   23 |     vector<long long> first(k);
      |            ^~~~
books.cpp:26:9: error: 'first' was not declared in this scope
   26 |         first[i] = skim(i + 1);
      |         ^~~~~
books.cpp:26:20: error: 'skim' was not declared in this scope
   26 |         first[i] = skim(i + 1);
      |                    ^~~~
books.cpp:29:30: error: 'first' was not declared in this scope
   29 |     if (r != n && sumFirst - first.back() + found <= 2 * a) {
      |                              ^~~~~
books.cpp:31:9: error: 'answer' was not declared in this scope
   31 |         answer(ans);
      |         ^~~~~~
books.cpp:35:12: error: expected primary-expression before 'long'
   35 |     vector<long long> last(k);
      |            ^~~~
books.cpp:38:9: error: 'last' was not declared in this scope
   38 |         last[n - 1 - i] = skim(i + 1);
      |         ^~~~
books.cpp:38:27: error: 'skim' was not declared in this scope
   38 |         last[n - 1 - i] = skim(i + 1);
      |                           ^~~~
books.cpp:42:9: error: 'answer' was not declared in this scope
   42 |         answer(ans);
      |         ^~~~~~
books.cpp:47:9: error: 'answer' was not declared in this scope
   47 |         answer(ans);
      |         ^~~~~~
books.cpp:51:9: error: 'impossible' was not declared in this scope
   51 |         impossible();
      |         ^~~~~~~~~~
books.cpp:58:16: error: 'first' was not declared in this scope
   58 |         sum -= first[i];
      |                ^~~~~
books.cpp:59:16: error: 'last' was not declared in this scope
   59 |         sum += last[k - 1 - i];
      |                ^~~~
books.cpp:62:5: error: 'answer' was not declared in this scope
   62 |     answer(ans);
      |     ^~~~~~