Submission #108326

# Submission time Handle Problem Language Result Execution time Memory
108326 2019-04-28T14:09:25 Z kuroni Gap (APIO16_gap) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include "gap.h"
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:17:34: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
             MinMax(le, ri, mi, ma);
                                  ^
In file included from gap.cpp:5:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:17:34: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
             MinMax(le, ri, mi, ma);
                                  ^
In file included from gap.cpp:5:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:30:31: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
         MinMax(0, 1E18, le, ri);
                               ^
In file included from gap.cpp:5:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:30:31: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
         MinMax(0, 1E18, le, ri);
                               ^
In file included from gap.cpp:5:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:36:55: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
             MinMax(le, le + ga + (i <= mo) - 1, mi, ma);
                                                       ^
In file included from gap.cpp:5:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:36:55: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
             MinMax(le, le + ga + (i <= mo) - 1, mi, ma);
                                                       ^
In file included from gap.cpp:5:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:48:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < ve.size(); i++)
                     ~~^~~~~~~~~~~