제출 #713187

#제출 시각아이디문제언어결과실행 시간메모리
713187lamGap (APIO16_gap)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #include "gap.h" using namespace std; #define ll long long const int maxn = 1e5 + 10; int n; ll a[maxn]; ll sub1() { int l=1; int r=n; ll s = 0; ll t = 1e18; while (l<=r) { ll *mx, *mn; ll mmax, mmin; mx = &mmax; mn = &mmin; // cerr<<l<<' '<<r<<' '<<s<<' '<<t<<endl; MinMax(s,t,mn,mx); s = (mmin)+1; t = (mmax)-1; a[l++]=mmin; a[r--]=mmax; } ll ans = 0; for (int i=2; i<=n; i++) { if (ans<a[i]-a[i-1]) ans=a[i]-a[i-1]; } return ans; } set<ll> b; ll sq = 20; void dnc(ll s, ll t) { if (s>t) return; ll *mn,*mx; ll mmin,mmax; mx = &mmax; mn=&mmin; MinMax(s,t,mn,mx); if (mmin == -1) return; s = mmin+1; t = mmax-1; b.insert(mmin); b.insert(mmax); if (mmin==mmax) return; ll dist = 1LL*(t-s)/sq; ll last = s; for (ll i=1; i<sq; i++) { ll next = min(last + dist,t); dnc(last,next); last = next + 1; if (last > t) break; } if (last <= t) dnc(last,t); } ll sub2() { dnc(0,1e18); int m=0; for (ll i:b) a[++m] = i; ll ans = 0; assert(n==m); for (int i=2; i<=n; i++) ans=max(ans,a[i]-a[i-1]); return ans; } ll findGap(int T, int N) { n=N; sq = max(2LL,sqrt(n)); if (T==1) return sub1(); else return sub2(); }

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:74:25: error: no matching function for call to 'max(long long int, __gnu_cxx::__enable_if<true, double>::__type)'
   74 |     sq = max(2LL,sqrt(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: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:74:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   74 |     sq = max(2LL,sqrt(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: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:74:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   74 |     sq = max(2LL,sqrt(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: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:74:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   74 |     sq = max(2LL,sqrt(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: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:74:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   74 |     sq = max(2LL,sqrt(n));
      |                         ^