Submission #94061

# Submission time Handle Problem Language Result Execution time Memory
94061 2019-01-15T15:09:47 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:16:34: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
             MinMax(le, ri, Mn, Mx);
                                  ^
In file included from gap.cpp:2: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:16:34: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
             MinMax(le, ri, Mn, Mx);
                                  ^
In file included from gap.cpp:2: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:27:26: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
     MinMax(le, ri, Mn, Mx);
                          ^
In file included from gap.cpp:2: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:27:26: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
     MinMax(le, ri, Mn, Mx);
                          ^
In file included from gap.cpp:2: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:41:30: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
         MinMax(le, ri, Mn, Mx);
                              ^
In file included from gap.cpp:2: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:41:30: error: invalid conversion from 'll {aka long long int}' to 'long long int*' [-fpermissive]
         MinMax(le, ri, Mn, Mx);
                              ^
In file included from gap.cpp:2: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:49:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < A.size(); i += 2)
                     ~~^~~~~~~~~~