Submission #535481

#TimeUsernameProblemLanguageResultExecution timeMemory
535481byunjaewooGap (APIO16_gap)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll=long long; #include "gap.h" ll findGap(int T, int N) { if(T==1) { ll res=0, s=-1, e=(ll)1e18+1; vector<int> V; for(int i=1; i<=(N+1)/2; i++) { MinMax(s+1, e-1, &s, &e); V.push_back(s); if(s!=e) V.push_back(e); } sort(V.begin(), V.end()); for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]); return res; } ll s, e, res=0; MinMax(0, (ll)1e18, &s, &e); s++, e--; vector<ll> a, b; for(ll i=1; i<=N+1; i++) { ll l=s+((e-s+1)*(i-1)/N), r=min(e, s+((e-s+1)*i/N-1)); if(l>r) continue; ll x, y; MinMax(l, r, &x, &y); if(x!=-1) { a.push_back(x); b.push_back(y); } } if(a.size()) res=max(a[0]-s+1, e-b.back()+1); for(int i=0; i<a.size()-1; i++) res=max(res, a[i+1]-b[i]); return res; }

Compilation message (stderr)

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]);
      |                      ~^~~~~~~~~~~
gap.cpp:16:65: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   16 |         for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]);
      |                                                                 ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
gap.cpp:16:65: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   16 |         for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]);
      |                                                                 ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
gap.cpp:16:65: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   16 |         for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]);
      |                                                                 ^
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:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
gap.cpp:16:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   16 |         for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]);
      |                                                                 ^
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:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
gap.cpp:16:65: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   16 |         for(int i=0; i<V.size()-1; i++) res=max(res, V[i+1]-V[i]);
      |                                                                 ^
gap.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0; i<a.size()-1; i++) res=max(res, a[i+1]-b[i]);
      |                  ~^~~~~~~~~~~