Submission #94062

# Submission time Handle Problem Language Result Execution time Memory
94062 2019-01-15T15:12:02 Z Kastanda Gap (APIO16_gap) C++11
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "gap.h"
#define pb push_back
using namespace std;
typedef long long ll;
inline ll findGap(int task, int n)
{
    if (task == 1)
    {
        int l = 1, r = n;
        ll le = 0, ri = 1e18;
        ll Mn, Mx;
        vector < ll > A(n + 1);
        while (l <= r)
        {
            MinMax(le, ri, &Mn, &Mx);
            A[l ++] = Mn; A[r --] = Mx;
            le = Mn + 1; ri = Mx - 1;
        }
        Mx = 0;
        for (int i = 1; i < n; i++)
            Mx = max(Mx, A[i + 1] - A[i]);
        return Mx;
    }
    ll Mn, Mx;
    ll le = 0, ri = 1e18;
    MinMax(le, ri, &Mn, &Mx);
    if (Mx - Mn <= n - 1)
        return 1LL;
    ll len = (Mx - Mn - 1) / (n - 1);
    ll cnt = (Mx - Mn - 1) % (n - 1);

    le = Mn + 1;
    ll last = Mx;
    vector < ll > A = {Mn};
    for (int i = 1; i <= n - 1; i++)
    {
        ri = le + len - 1;
        if (i <= cnt)
            ri ++;
        MinMax(le, ri, &Mn, &Mx);
        le = ri + 1;
        if (Mn == -1)
            continue;
        A.pb(Mn);
        A.pb(Mx);
    }
    A.pb(last); Mx = 0;
    for (int i = 1; i < A.size(); i += 2)
        Mx = max(Mx, A[i] - A[i - 1]);
    return Mx;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:49:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < A.size(); i += 2)
                     ~~^~~~~~~~~~
/tmp/ccrBL4OL.o: In function `main':
grader.cpp:(.text.startup+0x18e): undefined reference to `findGap(int, int)'
collect2: error: ld returned 1 exit status