제출 #556941

#제출 시각아이디문제언어결과실행 시간메모리
556941kymA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#include "books.h"
#define s second 
#define f first 
#define pb push_back
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
typedef pair <long long ,int> pi;
using namespace std;
#ifdef LOCAL
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
#define reach cerr << "LINE: " << __LINE__ << "\n";
#else
#define db(x)
#define db2(x,y)
#define db3(a,b,c)
#define dbv(v)
#define dbvp(v)
#define dba(a,ss,ee)
#define reach
#endif
//
// --- 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.
//


/*
SAMPLE GRADER for task BOOKS

USAGE:
place together with your solution and books.h in the same directory, then:
g++ <flags> sample_grader.cpp <solution_file>
e.g.:
g++ -std=c++17 sample_grader.cpp books.cpp

INPUT/OUTPUT:
The sample grader expects on standard input two lines. The first line should
contain the four integers N, K, A and S. The second line should contain a list
of N integers, the sequence of difficulties x_1 x_2 ... x_N which has to be
strictly increasing. Then, the grader writes to standard output a protocol of
all grader functions called by your program.
At the end, the grader prints your verdict.
*/

void solve(int n, int k, long long a, int s) {
    ll lo = 0, hi = n+1;
    while(lo<hi-1) {
    	ll mid = (lo+hi)/2;
    	ll x = skim(mid);
    	if(x*k >= a)hi=mid;
    	else lo=mid;
    }
    cerr << hi << '\n';
    vector<pi> v;
    FOR(i,hi-k,hi+k) {
    	if(i<=0||i>n)continue;
    	v.pb(pi(skim(i),i));
    }
    FOR(i,0,(1<<(v.size()))-1) {
    	if(__builtin_popcount(i) != k)continue;
    	int tot = 0;
    	vector<int> res;
    	FOR(j,0,v.size()-1) {
    		if(i&(1<<j)) {
    			tot += v[j].f;
    			res.pb(v[j].s);
    		}
    	}
    	dbv(res);
    	db(tot);
    	if(tot >= a && tot <= 2*a){
    		

    		answer(res);
    		//exit(0);
    	}
    }
    impossible();
    
}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:57:5: error: 'll' was not declared in this scope
   57 |     ll lo = 0, hi = n+1;
      |     ^~
books.cpp:58:11: error: 'lo' was not declared in this scope; did you mean 'log'?
   58 |     while(lo<hi-1) {
      |           ^~
      |           log
books.cpp:58:14: error: 'hi' was not declared in this scope; did you mean 'pi'?
   58 |     while(lo<hi-1) {
      |              ^~
      |              pi
books.cpp:59:8: error: expected ';' before 'mid'
   59 |      ll mid = (lo+hi)/2;
      |        ^~~~
      |        ;
books.cpp:60:8: error: expected ';' before 'x'
   60 |      ll x = skim(mid);
      |        ^~
      |        ;
books.cpp:61:9: error: 'x' was not declared in this scope
   61 |      if(x*k >= a)hi=mid;
      |         ^
books.cpp:61:21: error: 'mid' was not declared in this scope
   61 |      if(x*k >= a)hi=mid;
      |                     ^~~
books.cpp:62:14: error: 'mid' was not declared in this scope
   62 |      else lo=mid;
      |              ^~~
books.cpp:64:13: error: 'hi' was not declared in this scope; did you mean 'pi'?
   64 |     cerr << hi << '\n';
      |             ^~
      |             pi
books.cpp:66:9: error: expected ';' before 'i'
   66 |     FOR(i,hi-k,hi+k) {
      |         ^
books.cpp:7:27: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                           ^
books.cpp:66:9: error: 'i' was not declared in this scope
   66 |     FOR(i,hi-k,hi+k) {
      |         ^
books.cpp:7:34: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                                  ^
books.cpp:66:16: error: expected ';' before 'hi'
   66 |     FOR(i,hi-k,hi+k) {
      |                ^~
books.cpp:7:43: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                                           ^
books.cpp:7:44: error: expected ')' before ';' token
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                       ~                    ^
books.cpp:66:5: note: in expansion of macro 'FOR'
   66 |     FOR(i,hi-k,hi+k) {
      |     ^~~
books.cpp:66:9: error: 'i' was not declared in this scope
   66 |     FOR(i,hi-k,hi+k) {
      |         ^
books.cpp:7:48: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                                                ^
books.cpp:70:9: error: expected ';' before 'i'
   70 |     FOR(i,0,(1<<(v.size()))-1) {
      |         ^
books.cpp:7:27: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                           ^
books.cpp:74:10: error: expected ';' before 'j'
   74 |      FOR(j,0,v.size()-1) {
      |          ^
books.cpp:7:27: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                           ^
books.cpp:74:10: error: 'j' was not declared in this scope
   74 |      FOR(j,0,v.size()-1) {
      |          ^
books.cpp:7:34: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                                  ^
books.cpp:74:14: error: expected ';' before 'v'
   74 |      FOR(j,0,v.size()-1) {
      |              ^
books.cpp:7:43: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                                           ^
books.cpp:74:22: warning: value computed is not used [-Wunused-value]
   74 |      FOR(j,0,v.size()-1) {
      |              ~~~~~~~~^~
books.cpp:7:43: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                                           ^
books.cpp:7:44: error: expected ')' before ';' token
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                       ~                    ^
books.cpp:74:6: note: in expansion of macro 'FOR'
   74 |      FOR(j,0,v.size()-1) {
      |      ^~~
books.cpp:74:10: error: 'j' was not declared in this scope
   74 |      FOR(j,0,v.size()-1) {
      |          ^
books.cpp:7:48: note: in definition of macro 'FOR'
    7 | #define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
      |                                                ^