Submission #646352

#TimeUsernameProblemLanguageResultExecution timeMemory
646352Tenis0206Gap (APIO16_gap)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "gap.h"

using namespace std;

long long bck = 1000;

struct nod
{
    long long val,Min,Max;
};

nod divide1(long long st, long long dr)
{
    if(st > dr)
    {
        return nod{-1,-1,-1};
    }
    long long x,y;
    MinMax(st,dr,&x,&y);
    if(x==-1)
    {
        return nod{-1,-1,-1};
    }
    if(x==y)
    {
        return nod{-1,x,y};
    }
    long long mij = (x + y) >> 1;
    nod l = divide1(x+1,mij);
    nod r = divide1(mij+1,y-1);
    long long rez = -1;
    if(l.Max!=-1 && r.Min!=-1)
    {
        rez = max(rez,r.Min-l.Max);
    }
    rez = max(rez,l.val);
    rez = max(rez,r.val);
    long long Max = max(l.Max,r.Max);
    long long Min;
    if(l.Min==-1)
    {
        Min = r.Min;
    }
    else
    {
        Min = l.Min;
    }
    if(Min!=-1)
    {
        rez = max(rez,Min - x);
    }
    if(Max!=-1)
    {
        rez = max(rez,y - Max);
    }
    return nod{rez,x,y};
}

nod divide2(long long st, long long dr)
{
    if(st > dr)
    {
        return nod{-1,-1,-1};
    }
    long long x,y;
    MinMax(st,dr,&x,&y);
    if(x==-1)
    {
        return nod{-1,-1,-1};
    }
    if(x==y)
    {
        return nod{-1,x,y};
    }
    long long last = st - 1;
    long long rez = -1;
    long long Max = -1;
    for(int i=1;i<=bck;i++)
    {
        long long mij = st + ((dr - st) / bck) * i;
        if(i==bck)
        {
            mij = dr;
        }
        nod son = divide2(last+1,mij);
        last = mij;
        rez = max(rez,son.val);
        if(Max!=-1 && son.Min!=-1)
        {
            rez = max(rez,son.Min - Max);
        }
        if(son.Max!=-1)
        {
            Max = son.Max;
        }
    }
    return nod{rez,x,y};
}

long long findGap(int t, int n)
{
    bck = min(bck,n);
    return divide2(1,1e18).val;
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:103:20: error: no matching function for call to 'min(long long int&, int&)'
  103 |     bck = min(bck,n);
      |                    ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
gap.cpp:103:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  103 |     bck = min(bck,n);
      |                    ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
gap.cpp:103:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  103 |     bck = min(bck,n);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
gap.cpp:103:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  103 |     bck = min(bck,n);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
gap.cpp:103:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  103 |     bck = min(bck,n);
      |                    ^