Submission #646373

#TimeUsernameProblemLanguageResultExecution timeMemory
646373Tenis0206Gap (APIO16_gap)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; int n; long long bck = 1000; int pmax = 0; struct nod { long long val,Min,Max; }; long long solve1() { int l = 1; int r = n; long long st = 0, dr = 1e18; vector<long long> a,b; while(l<=r) { long long x,y; MinMax(st,dr,&x,&y); a.push_back(x); b.push_back(y); ++l; --r; st = x + 1; dr = y - 1; } vector<long long> v; for(auto it : a) { v.push_back(it); } reverse(b.begin(),b.end()); for(auto it : b) { v.push_back(it); } long long Max = 0; for(int i=1;i<v.size();i++) { Max = max(Max,v[i] - v[i-1]); } return Max; } 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}; } if(st==1 && dr==1e18) { pmax = (y - x + n) / (n - 1); } st = x, dr = y; if(dr - st + 1 <= pmax) { 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; } if(Max!=-1) { last = Max; } 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; } if(mij==dr) { break; } } return nod{rez,x,y}; } long long findGap(int t, int N) { n = N; if(t==1) { return solve1(); } bck = min(bck,n); return divide2(1,1e18).val; }

Compilation message (stderr)

gap.cpp: In function 'long long int solve1()':
gap.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=1;i<v.size();i++)
      |                 ~^~~~~~~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:116:20: error: no matching function for call to 'min(long long int&, int&)'
  116 |     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:116:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  116 |     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:116:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  116 |     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:116:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  116 |     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:116:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  116 |     bck = min(bck,n);
      |                    ^