Submission #744093

#TimeUsernameProblemLanguageResultExecution timeMemory
744093myrcellaA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
//by szh #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define mod 1000000007 typedef long long ll; #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} #include "books.h" const int maxn = 1e5+10; ll dif[maxn]; ll AA; ll check(int pos) { ll ret = 0; rep(i,pos-K+1,pos+1) { if (dif[i]==-1) dif[i] = skim(i); ret += dif[i]; ret = min(ret,2*AA); } return ret; } void solve(int N, int K, long long A, int S) { AA = A; memset(dif,-1,sizeof(dif)); // TODO implement this function if (S==N) { rep(i,1,N+1) dif[i] = skim(i); ll sum = 0; rep(i,1,K+1) { sum += dif[i]; if (sum>2*A) impossible(); } vector <int> ret; if (sum>=A) { rep(i,1,K+1) ret.pb(i); answer(ret); } rep(i,K+1,N+1) { sum += dif[i]; sum -= dif[i-K]; if (sum>2*A) { if (dif[i]>2*A) impossible(); ll sum1 = 0; rep(j,1,K) ret.pb(j),sum1 += dif[j]; ret.pb(i);sum1+=dif[i]; if (sum1<=2*A) answer(ret); impossible(); } if (sum>=A) { rep(j,i-K+1,i+1) ret.pb(j); answer(ret); } } impossible(); } int l = K, r = N; vector <int> ret; while (l+1<r) { int mid = l + r >> 1; ll tmp = check(mid); if (tmp < A) l = mid+1; else if (tmp > A + A) r = mid-1; else { rep(j,mid-K+1,mid+1) ret.pb(j); answer(ret); } } ll tmp = check(l); if (tmp>=A and tmp<=A+A) { rep(j,l-K+1,l+1) ret.pb(j); answer(ret); } if (l!=r) { ll tmp = check(r); if (tmp>=A and tmp<=A+A) { rep(j,r-K+1,r+1) ret.pb(j); answer(ret); } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'll check(int)':
books.cpp:32:12: error: 'K' was not declared in this scope
   32 |  rep(i,pos-K+1,pos+1) {
      |            ^
books.cpp:13:31: note: in definition of macro 'rep'
   13 | #define rep(i,a,b) for (int i=a;i<(b);i++)
      |                               ^
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:77:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   77 |   int mid = l + r >> 1;
      |             ~~^~~