제출 #941848

#제출 시각아이디문제언어결과실행 시간메모리
941848LCJLYA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; //code //skim() impossible() answer({}); #include <bits/stdc++.h> #define show(x,y) cout << y << " " << #x << endl; #define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl; #define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl; #define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl; long long memo[100005]; long long ask(int x){ if(memo[n]!=-1) return memo[n]; return memo[n]=skim(n); } void solve(int n, int k, long long a, int s) { memset(memo,-1,sizeof(memo)); long long hold=ask(n); vector<int>v; if(hold>=a){ long long counter=0; for(int x=1;x<k;x++){ v.push_back(x); counter+=ask(x); } int l=k; int r=n; int mid; while(l<=r){ mid=(l+r)/2; long long take=ask(mid); if(take+counter>=a&&take+counter<=2*a){ v.push_back(mid); answer(v); return; } else if(take+counter<a){ l=mid+1; } else r=mid-1; } impossible(); } else{ long long counter=0; vector<pair<long long,long long>>cur; for(int x=1;x<=k;x++){ cur.push_back({ask(x),x}); counter+=cur.back().first; } int ptr=n; //show(counter,counter); if((n==k&&counter<a)||counter>2*a){ impossible(); return; } while(counter<a&&!cur.empty()){ counter+=ask(ptr); v.push_back(ptr); ptr--; counter-=cur.back().first; cur.pop_back(); } if(counter>=a){ for(auto it:cur) v.push_back(it.second); answer(v); return; } impossible(); } } //code

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

books.cpp: In function 'long long int ask(int)':
books.cpp:18:10: error: 'n' was not declared in this scope
   18 |  if(memo[n]!=-1) return memo[n];
      |          ^
books.cpp:19:14: error: 'n' was not declared in this scope
   19 |  return memo[n]=skim(n);
      |              ^