제출 #793240

#제출 시각아이디문제언어결과실행 시간메모리
793240ToniBGap (APIO16_gap)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; typedef long long ll; const int MAXN = 1e5 + 2; ll K = 3; vector<ll> ans; ll f(ll L, ll R){ return max(1, (R - L + K - 1) / K); } void solve(ll L, ll R){ if(L > R) return ; ll d = f(L, R); for(ll i = L; i <= R; i += d){ ll val_l = i, val_r = min(R, i + d - 1); assert(val_l <= val_r); MinMax(val_l, val_r, &val_l, &val_r); if(val_l != -1){ ans.push_back(val_l); if(val_r != val_l){ ans.push_back(val_r); solve(val_l + 1, val_r - 1); } } } } ll findGap(int t, int n){ if(t == 1){ int L = 0, R = n - 1; ll val_l = 1, val_r = 1e18; while(L <= R){ MinMax(val_l, val_r, &val_l, &val_r); ans.push_back(val_l); if(val_r != val_l) ans.push_back(val_r); ++L; --R; ++val_l; --val_r; } } else { solve(1, 1e18); } ll ret = 0; sort(ans.begin(), ans.end()); for(int i = 0; i < (int)ans.size() - 1; ++i) ret = max(ret, ans[i + 1] - ans[i]); return ret; }

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'll f(ll, ll)':
gap.cpp:10:35: error: no matching function for call to 'max(int, ll)'
   10 |  return max(1, (R - L + K - 1) / K);
      |                                   ^
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:10:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   10 |  return max(1, (R - L + K - 1) / K);
      |                                   ^
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:10:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   10 |  return max(1, (R - L + K - 1) / K);
      |                                   ^
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:10:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   10 |  return max(1, (R - L + K - 1) / K);
      |                                   ^
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:10:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   10 |  return max(1, (R - L + K - 1) / K);
      |                                   ^