Submission #94060

# Submission time Handle Problem Language Result Execution time Memory
94060 2019-01-15T15:08:21 Z Kastanda Gap (APIO16_gap) C++11
Compilation error
0 ms 0 KB
#include<bits/stdc++.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:15:13: error: 'MinMax' was not declared in this scope
             MinMax(le, ri, Mn, Mx);
             ^~~~~~
gap.cpp:15:13: note: suggested alternative: 'rindex'
             MinMax(le, ri, Mn, Mx);
             ^~~~~~
             rindex
gap.cpp:26:5: error: 'MinMax' was not declared in this scope
     MinMax(le, ri, Mn, Mx);
     ^~~~~~
gap.cpp:26:5: note: suggested alternative: 'rindex'
     MinMax(le, ri, Mn, Mx);
     ^~~~~~
     rindex
gap.cpp:48:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < A.size(); i += 2)
                     ~~^~~~~~~~~~