Submission #668245

#TimeUsernameProblemLanguageResultExecution timeMemory
668245birthdaycakeGap (APIO16_gap)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "gap.h" using namespace std; long long findGap(long long T, long long N){ long long l = 0, r = 0, mn = 0, mx = 0; MinMax(1, 1000000000000000000, &mn, &mx); l = mn; r = mx; long long sz = (r - l + 1) / (N - 1); vector<pair<int,int>>d; for(int j = l; j <= r; j += sz+1){ MinMax(j, j + sz, &mn, &mx); d.push_back({mn, mz}); } long long ans = (r - l + 1) / (N - 1); mn = d[0].first; mx = d[0].second; for(int i = 1; i < d.size(); i++){ if(mx != -1 && d[i].first != -1){ ans = max(ans, d[i].first - mx); mn = d[i].first; mx = d[i].second; } } return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(long long int, long long int)':
gap.cpp:14:26: error: 'mz' was not declared in this scope; did you mean 'sz'?
   14 |         d.push_back({mn, mz});
      |                          ^~
      |                          sz
gap.cpp:14:29: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   14 |         d.push_back({mn, mz});
      |                             ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
gap.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i = 1; i < d.size(); i++){
      |                    ~~^~~~~~~~~~