Submission #38753

# Submission time Handle Problem Language Result Execution time Memory
38753 2018-01-06T12:22:02 Z oTTo_22 Gap (APIO16_gap) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "gap.h"
#define se second
#define fi first
using namespace std;

long long ans;

void func (long long L,long long R)
{
    long long mi1,ma1,mi2,ma2;
    long long mid=(L+R)/2;
    MinMax(L,mid,&mi1,&ma1);
    MinMax(mid,R,&mi2,&ma2);
    if (ma1==-1 && mi2==-1) {
        ans=max(ans,R-L);
        return;
    }
    if (ma1==-1) {
        ans=max(ans,mi2-L);
        return;
    }
    if (mi2==-1) {
        ans=max(ans,R-ma1);
        return;
    }
    if (ma1==L && mi2==R){
        ans=max(ans,R-L);
        return;
    }
    if (R-L==1){
        ans=max(ans,1);
        return;
    }
    if (ma1-L>ans)
        func(L,ma1);
    if (R-mi2>ans)
        func(mi2,R);
    if (mi2-ma1>ans)
        func (ma1,mi2);
}

long long findGap(int T, int N)
{
    int m=N;
    long long Mn,Mx;
    long long S=0;
    long long TT=1000000000000000000;
    MinMax(S,TT,&Mn,&Mx);
    if (m==2)
        return Mx-Mn;
    ans=0;
    func (Mn,Mx);
    return ans;
}

Compilation message

gap.cpp: In function 'void func(long long int, long long int)':
gap.cpp:32:22: error: no matching function for call to 'max(long long int&, int)'
         ans=max(ans,1);
                      ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
gap.cpp:32:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         ans=max(ans,1);
                      ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
gap.cpp:32:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         ans=max(ans,1);
                      ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3457:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^
/usr/include/c++/5/bits/stl_algo.h:3457:5: note:   template argument deduction/substitution failed:
gap.cpp:32:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         ans=max(ans,1);
                      ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from gap.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   template argument deduction/substitution failed:
gap.cpp:32:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         ans=max(ans,1);
                      ^