Submission #1328303

#TimeUsernameProblemLanguageResultExecution timeMemory
1328303nguyenkhangninh99Gap (APIO16_gap)C++20
Compilation error
0 ms0 KiB

#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll findGap(int t, int n){
    ll ans = 0;
    if(t == 1){
        vector<ll> a;
        ll l = 1, r = 1e18, mn, mx;
        while(a.size() < n){
            MinMax(l, r, &mn, &mx);
            if(mn == -1) break;
            a.push_back(mn);
            a.push_back(mx);
            l = mn + 1;
            r = mx - 1;
        }
        sort(a.begin(), a.end());
        for(int i = 0; i + 1 < a.size(); i++) ans = max(ans, a[i + 1] - a[i]);
    }else{
        ll st = INF, en = -INF;
        MinMax(0, INF, &st, &en);
        ll X = (en - st + N - 2) / (N - 1);
        ll x = st;
        ll premx = -1;
        ans = X;
        int cnt = 0;
        while(x <= en){
            cnt++;
            ll mn = INF, mx = -INF, nxx = x + X;
            MinMax(x, nxx, &mn, &mx);
            if(premx != -1 && mx != -1) ans = max(ans, mn - premx);
            if(mx != -1) premx = mx;
            x = nxx + 1;
        }
    }
    return ans;
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:24:17: error: 'INF' was not declared in this scope
   24 |         ll st = INF, en = -INF;
      |                 ^~~
gap.cpp:25:30: error: 'en' was not declared in this scope; did you mean 'n'?
   25 |         MinMax(0, INF, &st, &en);
      |                              ^~
      |                              n
gap.cpp:26:27: error: 'N' was not declared in this scope
   26 |         ll X = (en - st + N - 2) / (N - 1);
      |                           ^
gap.cpp:34:23: error: 'nxx' was not declared in this scope
   34 |             MinMax(x, nxx, &mn, &mx);
      |                       ^~~