제출 #795854

#제출 시각아이디문제언어결과실행 시간메모리
795854KLPPA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long int lld; #define rep(i,a,b) for(int i=a;i<b;i++) #define trav(a,v) for(auto a:v) // // --- 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. // map<int,lld> m; lld query(int pos){ if(m.find(pos)==m.end()){ lld x=skim(pos+1); m[pos]=x; return x; } return m[pos]; } void solve(int N, int K, long long A, int S) { int lo=-1; int hi=N; while(hi-lo>1){ int mid=(hi+lo)/2; if(query(mid)<=2*A){ lo=mid; }else hi=mid; } if(lo<k)impossible(); vector<pair<lld,int> > books; int k=K; rep(i,0,k){ books.push_back({query(i),i}); } for(int i=lo;i>lo-k && i>=0;i--){ books.push_back({query(i),i}); } sort(books.begin(),books.end()); books.resize(unique(books.begin(),books.end())-books.begin()); vector<int> St; rep(msk,0,(1<<books.size())){ lld sum=0; St.clear(); rep(i,0,(int)books.size()){ if((msk&(1<<i))>0){ St.push_back(books[i].second+1); sum+=books[i].first; } } if(sum>=A && sum<=2*A && (int)St.size()==k){ answer(St); } } impossible(); }

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:36:8: error: 'k' was not declared in this scope
   36 |  if(lo<k)impossible();
      |        ^