Submission #918246

#TimeUsernameProblemLanguageResultExecution timeMemory
918246hugsfromadictoA Difficult(y) Choice (BOI21_books)C++14
Compilation error
0 ms0 KiB
#include            <bits/stdc++.h>
#include            "books.h"
#define pb          push_back
#define pii         pair<int, int>
#define pll         pair<ll, ll>
#define vll         vector<ll>
#define all(v)      v.begin(), v.end()
#define whole(a)    a+1, a+1+n
#define OPT         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sec         second
#define fi          first
#define print(k)    cerr << "Ans : "; cout << k << endl;
#define ins         insert
#define pb          push_back 
#define bpc         __builtin_popcountll
#define skip        continue
#define endll          '\n'
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   a*b / (__gcd(a, b))
#define mpr         make_pair
#define rep(i,l,r)  for(ll i=l;i<=r;++i)
#define new         '\n'
typedef long long ll;
typedef unsigned long long ull;
const int mod = 998244353;
const int sz = 3e5+5;
using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

ll a[1000005];
ll ask(int i)
{
    if(!a[i])
    {
        a[i] = skim(i);
    }
    return a[i];
}
ll Sum(vector<int>v, int l,int r)
{
    ll res = 0;
    for(int i = l; i <= r; ++i)
    {
        res += ask[v[i]];
    }
    return res;
}
void solve(int N, int K, long long A, int S) {
    int l=0;
    for(int i=17;i>=0;i--){
        int nxt=l+(1<<i);
        if(nxt<=N&&ask(nxt)<=A)l=nxt;
    }
    if(l<=K-2)return impossible();
    vector<int>v;
    ll sum=0;
    for(int i=1;i<=K-1;i++)v.push_back(i),sum+=ask(i);
    if(l<N){
        v.push_back(l+1);
        sum+=ask(l+1);
        if(A<=sum&&sum<=2*A)return answer(v);
    }
    if(l<K)return impossible();
    vector<int>arr;
    for(int i=1;i<=K;i++)arr.push_back(i),arr.push_back(l-K+i);
    sort(arr.begin(),arr.end());
    arr.erase(unique(arr.begin(),arr.end()),arr.end());
    for(int i=K-1;i<arr.size();i++){
        if(A<=Sum(arr,i-K+1,i)&&Sum(arr,i-K+1,i)<=2*A){
            return answer(vector<int>(arr.begin()+i-K+1,arr.begin()+i+1));
        }
    }
    impossible();
}

Compilation message (stderr)

books.cpp: In function 'll Sum(std::vector<int>, int, int)':
books.cpp:45:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |         res += ask[v[i]];
      |                        ^
books.cpp:45:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |         res += ask[v[i]];
      |         ~~~~^~~~~~~~~~~~
books.cpp:45:24: error: invalid conversion from 'll (*)(int)' {aka 'long long int (*)(int)'} to 'll' {aka 'long long int'} [-fpermissive]
   45 |         res += ask[v[i]];
      |                        ^
      |                        |
      |                        ll (*)(int) {aka long long int (*)(int)}
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:69:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     for(int i=K-1;i<arr.size();i++){
      |                   ~^~~~~~~~~~~