제출 #1333730

#제출 시각아이디문제언어결과실행 시간메모리
1333730zhehanA Difficult(y) Choice (BOI21_books)C++20
컴파일 에러
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
  int ub = (2 * A) / K;
  int lb = (A + k - 1) / K;
  int l = 0, r = N, m;
  while (l < r) {
    m = (l + r + 1) / 2;
    int o = skim(m);
    if (o < ub) {
      l = m;
    } else if (o > ub) {
      r = m - 1;
    } else {
      l = m;
      break;
    }
  }
  int ubi = l;
  l = 0, r = N;
  while (l < r) {
    m = (l + r) / 2;
    int o = skim(m);
    if (o < lb) {
      l = m + 1;
    } else if (o > lb) {
      r = m;
    } else {
      r = m;
      break;
    }
  }
  int lbi = r;
  if (ubi - lbi + 1 >= K) {
    vector<int> books;
    for (int i = lbi, i < lbi + K; ++i) {
      books.push_back(i);
    }
    return books;
  }
}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:19:17: error: 'k' was not declared in this scope
   19 |   int lb = (A + k - 1) / K;
      |                 ^
books.cpp:50:24: error: expected ';' before '<' token
   50 |     for (int i = lbi, i < lbi + K; ++i) {
      |                        ^~
      |                        ;
books.cpp:50:25: error: expected primary-expression before '<' token
   50 |     for (int i = lbi, i < lbi + K; ++i) {
      |                         ^
books.cpp:53:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   53 |     return books;
      |            ^~~~~