Submission #108325

# Submission time Handle Problem Language Result Execution time Memory
108325 2019-04-28T14:08:07 Z kuroni Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

long long findGap(int t, int n)
{
    vector<long long> ve;
    if (t == 1)
    {
        long long le = 0, ri = 1E18;
        while (le <= ri)
        {
            long long mi, ma;
            MinMax(le, ri, mi, ma);
            if (mi > -1)
            {
                ve.push_back(mi);
                if (ma != mi)
                    ve.push_back(ma);
            }
            le = mi + 1; ri = ma - 1;
        }
    }
    if (t == 2)
    {
        long long le, ri;
        MinMax(0, 1E18, le, ri);
        ve.push_back(le++); ve.push_back(ri--);
        long long ga = (ri - le + 1) / (n - 1), mo = (ri - le + 1) % (n - 1);
        for (int i = 1; i < n; i++)
        {
            long long mi, ma;
            MinMax(le, le + ga + (i <= mo) - 1, mi, ma);
            le += ga + (i <= mo);
            if (mi > -1)
            {
                ve.push_back(mi);
                if (ma != mi)
                    ve.push_back(ma);
            }
        }
    }
    sort(ve.begin(), ve.end());
    long long ans = 0;
    for (int i = 1; i < ve.size(); i++)
        ans = max(ans, ve[i] - ve[i - 1]);
    return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:16:13: error: 'MinMax' was not declared in this scope
             MinMax(le, ri, mi, ma);
             ^~~~~~
gap.cpp:29:9: error: 'MinMax' was not declared in this scope
         MinMax(0, 1E18, le, ri);
         ^~~~~~
gap.cpp:47:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < ve.size(); i++)
                     ~~^~~~~~~~~~~