Submission #1083367

# Submission time Handle Problem Language Result Execution time Memory
1083367 2024-09-03T03:27:10 Z dong_gas Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#include "gap.h"

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll a[100201];
ll l[100201], r[100201];
pll b[100201];
const ll inf = 1'000'000'000'000'000'000;

ll findGap(ll T, ll n) {
    ll mn, mx, ret = 0;
    MinMax(0, inf, &mn, &mx);
    a[1] = mn, a[n] = mx;
    ll gap = (mx - mn) / n;
    for (ll i = a[1], cnt = 1; cnt <= n; i += gap, cnt++) {
        l[cnt] = i, r[cnt] = i + gap;
        if (cnt == n) r[cnt] = a[n];
    }
    bool full = true;
    for (int i = 1; i <= n; i++) {
        MinMax(l[i], r[i], &mn, &mx);
        b[i] = {mn, mx};
        if (mn == -1) full = false;
        ret = max(ret, mx - mn);
    }
    if (full) {
        for (int i = 2; i <= n; i++) {
            ret = max(ret, b[i].first - b[i - 1].first);
        }
    } 
    else {
        ll bef = -1;
        for (int i = 1; i <= n; i++) {
            if (b[i].first == -1) continue;
            MinMax(bef, b[i].first, &mn, &mx);
            ret = max(ret, mx - mn);
            bef = b[i].second;
        }
    }
    return ret;
}

Compilation message

/usr/bin/ld: /tmp/ccjHwG7A.o: in function `main':
grader.cpp:(.text.startup+0x1b7): undefined reference to `findGap(int, int)'
collect2: error: ld returned 1 exit status