제출 #944696

#제출 시각아이디문제언어결과실행 시간메모리
944696thelegendary08A Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long ll; // // --- 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) { vector<long long int>v(N); ll s = 0; for(int i = 1;i<=K-1;i++){ v[i-1] = skim(i); s += v[i-1]; } v[N-1] = skim(N); if(s + v[N-1] >= A && s + v[N-1] <= 2*A){ vector<int>ret; for(int i = 1;i<=K-1;i++){ ret.push_back(i); } ret.push_back(N); answer(ret); } if(s + v[N-1] < A){ s+= v[N-1]; //move until good then bsta bool ok = 0; int p = N-1; while(p > N - k && !ok){ ll cur = skim[p]; v[p-1] = cur; s-=v[N-p]; s+=v[p-1]; if(s >= A && s <= 2*A){ vector<int>ret; for(int i = 1;i<=K - (N-p+1);i++){ ret.pb(i); } for(int i = p;i<=N;i++)ret.pb(i); answer(ret); } else if(s >= A){ ok = 1; } } if(p == N - k)impossible(); s -= v[p-1]; int l = K - (N-p+1) + 1; int r = p-1; while(l <= r){ int k = (l + r)/2; int cur = skim(k); if(s + cur <= 2*A && s + cur >= A){ vector<int>ret; for(int i = 1;i<=K - (N-p+1);i++){ ret.pb(i); } ret.pb(k); for(int i = p+1;i<=N;i++)ret.pb(i); answer(ret); } else if(s + cur > 2*A)r = k-1; else l = k + 1; } } else{ //bsta int l = K; int r = N-1; } impossible(); }

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:39:23: error: 'k' was not declared in this scope
   39 |         while(p > N - k && !ok){
      |                       ^
books.cpp:40:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   40 |             ll cur = skim[p];
      |                            ^
books.cpp:40:28: error: invalid conversion from 'long long int (*)(int)' to 'll' {aka 'long long int'} [-fpermissive]
books.cpp:47:25: error: 'class std::vector<int>' has no member named 'pb'
   47 |                     ret.pb(i);
      |                         ^~
books.cpp:49:44: error: 'class std::vector<int>' has no member named 'pb'
   49 |                 for(int i = p;i<=N;i++)ret.pb(i);
      |                                            ^~
books.cpp:56:21: error: 'k' was not declared in this scope
   56 |         if(p == N - k)impossible();
      |                     ^
books.cpp:66:25: error: 'class std::vector<int>' has no member named 'pb'
   66 |                     ret.pb(i);
      |                         ^~
books.cpp:68:21: error: 'class std::vector<int>' has no member named 'pb'
   68 |                 ret.pb(k);
      |                     ^~
books.cpp:69:46: error: 'class std::vector<int>' has no member named 'pb'
   69 |                 for(int i = p+1;i<=N;i++)ret.pb(i);
      |                                              ^~
books.cpp:78:13: warning: unused variable 'l' [-Wunused-variable]
   78 |         int l = K;
      |             ^
books.cpp:79:13: warning: unused variable 'r' [-Wunused-variable]
   79 |         int r = N-1;
      |             ^