Submission #842299

# Submission time Handle Problem Language Result Execution time Memory
842299 2023-09-02T18:09:25 Z popovicirobert Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define lsb(x) (x & (-x))

using ull = unsigned long long;
using ll = long long;

using namespace std;

constexpr ll INF =  1e18;

vector<ll> arr;

#ifdef HOME

void MinMax(ll a, ll b, ll* mn, ll* mx) {
    *mn = INF;
    *mx = -INF;
    for (auto itr : arr) {
        if (itr >= a && itr <= b) {
            *mn = min(*mn, itr);
            *mx = max(*mx, itr);
        }
    }
    if (*mn == INF) {
        *mn = -1;
    }
    if (*mx == -INF) {
        *mx = -1;
    }
}

#endif

pair<ll, ll> Query(ll a, ll b) {
    ll mn, mx;
    MinMax(a, b, &mn, &mx);
    return {mn, mx};
}

ll findGap(int T, int N) {
    pair<ll, ll> res = Query(0, INF);
    
    ll a1 = res.first;
    ll an = res.second;
    ll step = (an - a1 + N - 2) / (N - 1);

    ll answer = 0;

    ll curr = a1;
    while (curr < an) {
        int x = 0;
        do {
            x++;
            res = Query(curr + 1, curr + step * x);
            if (res.second != -1) {
                break;
            }
        } while (true);

        answer = max(answer, res.first - curr);
        curr = res.second;
    }

    return answer;
}

Compilation message

gap.cpp: In function 'std::pair<long long int, long long int> Query(ll, ll)':
gap.cpp:37:5: error: 'MinMax' was not declared in this scope
   37 |     MinMax(a, b, &mn, &mx);
      |     ^~~~~~