제출 #941542

#제출 시각아이디문제언어결과실행 시간메모리
941542XiaoyangA Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define fi first 
#define se second 
#define pll pair<ll,ll>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl;
#define MP make_pair
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()
#define endl "\n"
const ll inf=1e18;

const ll maxn=1e5+5;
ll diff[maxn];

ll d(ll x){
	if(diff[x])return diff[x];
	return diff[x]=skim(x);
}
void solve(int n, int k, long long A, int s) {
    // TODO implement this function
    if(s==n and n<=1000 and k==3){
		rep(i,1,n+1){
			diff[i]=skim(i);
		}
		diff[n+1]=inf;
		rep(i,1,n-1){
			rep(j,i+1,n){
				ll sum=diff[i]+diff[j];
				ll id=lower_bound(diff+j+1,diff+n+1,A-sum)-diff;
				if(id==n+1 or diff[i]+diff[j]+diff[id]>2*A)break;
				else{
					vector<int>ans;
					ans.pb(i);
					ans.pb(j);
					ans.pb(id);
					answer(ans);
					return;
				}
			}
		}
		impossible();
	}
	
	int lo=1,hi=n;
	while(lo<hi){
		ll mid=(lo+hi)>>1;
		if(d(mid)<(A+k-1)/k)lo=mid+1;
		else hi=mid;
	}
	if(lo+k>n){
		impossible();
	}
	if(lo!=1){
		ll tmp=0;
		vector<ll>ans;
		rep(i,lo-1,lo+k-1){
			tmp+=d(i);
			ans.pb(i);
		}
		if(tmp>=a)answer(ans);
	}
	if(lo+k+1<=n+1){
		ll tmp=0;
		vector<ll>ans;
		rep(i,lo+1,lo+k+1){
			tmp+=d(i);
			ans.pb(i);
		}
		if(tmp<=2*a)answer(ans);
	}
	vector<int>ans;
	rep(i,lo,min(lo+k,n+1))ans.pb(i);
	answer(ans);
}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:67:11: error: 'a' was not declared in this scope
   67 |   if(tmp>=a)answer(ans);
      |           ^
books.cpp:67:20: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   67 |   if(tmp>=a)answer(ans);
      |                    ^~~
      |                    |
      |                    vector<long long int>
books.cpp:76:13: error: 'a' was not declared in this scope
   76 |   if(tmp<=2*a)answer(ans);
      |             ^
books.cpp:76:22: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   76 |   if(tmp<=2*a)answer(ans);
      |                      ^~~
      |                      |
      |                      vector<long long int>