Submission #956213

#TimeUsernameProblemLanguageResultExecution timeMemory
956213petezaGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include "gap.h" #include <iostream> #include <vector> #include <utility> using ll = long long; const ll inf = 2e18; long long findGap(int T, int N) { if(T==1) { ll cmin=0, cmax=inf, l=0, r=0; std::vector<ll> v1, v2; while(cmin <= cmax && v1.size() + v2.size() < N) { MinMax(cmin, cmax, &l, &r); if(l == -1) break; v1.push_back(l); if(l != r) v2.push_back(r); cmin = l+1; cmax = r-1; } ll amax = v2.back() - v1.back(); for(int i=0;i<v1.size()-1;i++) amax = std::max(amax, v1[i+1] - v1[i]); for(int i=0;i<v2.size()-1;i++) amax = std::max(amax, v2[i] - v2[i+1]); return amax; } else { ll rmin, rmax, l, r; MinMax(0, inf, &rmin, &rmax); ll amax = 1, i=1; while(rmin < rmax) { for(;i<=inf;i<<=1) { MinMax(rmin+1, rmin+i, &l, &r); if(l != -1) break; } if((i >> 1) >= amax) i >>= 1; i = max(i, 1ll); amax = std::max(amax, l-rmin); rmin = r; } return amax; } }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:47: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |   while(cmin <= cmax && v1.size() + v2.size() < N) {
      |                         ~~~~~~~~~~~~~~~~~~~~~~^~~
gap.cpp:19:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(int i=0;i<v1.size()-1;i++) amax = std::max(amax, v1[i+1] - v1[i]);
      |               ~^~~~~~~~~~~~
gap.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i=0;i<v2.size()-1;i++) amax = std::max(amax, v2[i] - v2[i+1]);
      |               ~^~~~~~~~~~~~
gap.cpp:32:15: error: 'max' was not declared in this scope; did you mean 'std::max'?
   32 |           i = max(i, 1ll);
      |               ^~~
      |               std::max
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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from gap.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~