제출 #401146

#제출 시각아이디문제언어결과실행 시간메모리
401146galcaA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> using namespace std; int findA(vector<long long>& books, long long A, int lower, int upper) { if (books[lower] == -1) { books[lower] = skim(lower + 1); } if (books[upper] == -1) { books[upper] = skim(upper + 1); } if (books[lower] > A) { return -1; } if (books[upper] <= A) { return upper; } if (upper == lower) { return lower; } int half = (upper - lower + 1) / 2; books[lower + half] = skim(lower + half + 1); if (books[lower + half] < A) return findA(books, A, lower + half, upper); else return findA(books, A, lower, lower + half); } void solve(int N, int K, long long A, int S) { if (K > N) { impossible(); return 0; } vector<long long> books(N); for (int i = 0; i < N; i++) { books[i] = -1; } int posA = findA(books, A, 0, N - 1); if (posA == -1) { impossible(); } else { if (posA == (N - 1)) { long long sum = 0; vector<int> res; for (int i = 0; i < K; i++) { res.push_back(N - i); if (books[i] == -1) { books[i] = skim(i + 1); } sum += books[i]; } if (sum < A) { impossible(); } answer(res); } else { vector<int> res; int lastPos = posA + 1 + K; if (lastPos > N) { lastPos = N; } for (int i = 0; i < K; i++) { res.push_back(lastPos - i); } answer(res); } } return 0; } int main() { return 0; }

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

books.cpp: In function 'int findA(std::vector<long long int>&, long long int, int, int)':
books.cpp:8:18: error: 'skim' was not declared in this scope
    8 |   books[lower] = skim(lower + 1);
      |                  ^~~~
books.cpp:11:18: error: 'skim' was not declared in this scope
   11 |   books[upper] = skim(upper + 1);
      |                  ^~~~
books.cpp:25:24: error: 'skim' was not declared in this scope
   25 |  books[lower + half] = skim(lower + half + 1);
      |                        ^~~~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:33:3: error: 'impossible' was not declared in this scope
   33 |   impossible();
      |   ^~~~~~~~~~
books.cpp:34:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
   34 |   return 0;
      |          ^
books.cpp:43:3: error: 'impossible' was not declared in this scope
   43 |   impossible();
      |   ^~~~~~~~~~
books.cpp:52:17: error: 'skim' was not declared in this scope
   52 |      books[i] = skim(i + 1);
      |                 ^~~~
books.cpp:57:5: error: 'impossible' was not declared in this scope
   57 |     impossible();
      |     ^~~~~~~~~~
books.cpp:59:4: error: 'answer' was not declared in this scope
   59 |    answer(res);
      |    ^~~~~~
books.cpp:71:4: error: 'answer' was not declared in this scope
   71 |    answer(res);
      |    ^~~~~~
books.cpp:74:9: error: return-statement with a value, in function returning 'void' [-fpermissive]
   74 |  return 0;
      |         ^