제출 #1155440

#제출 시각아이디문제언어결과실행 시간메모리
1155440SangGap (APIO16_gap)C++20
컴파일 에러
0 ms0 KiB
#ifndef _Pbrngw_ #include "gap.h" #endif // _Pbrngw_ #include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--) #define fi first #define se second #define pb push_back #define ALL(a) (a).begin(), (a).end() #define task "kbsiudthw" typedef vector<int> vi; typedef pair<int, int> ii; typedef pair<int, ii> pii; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 2277; long long findGap(int T, int N) { if (T == 1){ vi A; long long x = 0, y = 1e18; MinMax(0, 1e18, &x, &y); A.pb(x); A.pb(y); while (y - x > 1){ MinMax(x+1, y - 1, &x, &y); if(x == -1) break; A.pb(x); if (x != y) A.pb(y); } sort(ALL(A)); long long ans = 0; FOR (i, 0, N - 2) ans = max(ans, A[i+1] - A[i]); return ans; } long long A, B, C1, C2; MinMax(0, 1e18, &A, &B); if (N == 2) return B - A; long long block = (B - A - 1)/(N - 2); if ((B - A - 1)%(N-2)) ++block; long long last = A, ans = 0; for (long long i = A+1; i < B; i += block){ long long x, y; MinMax(i, min(B - 1, i + block - 1), &x, &y); if (x == -1) continue; ans = max(ans, x - last); last = y; } ans = max(ans, B - last); return ans; } #ifdef _Pbrngw_ signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } return 0; } #endif // _Pbrngw_

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:40:37: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   40 |         FOR  (i, 0, N - 2) ans = max(ans, A[i+1] - A[i]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from gap.cpp:4:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
gap.cpp:40:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   40 |         FOR  (i, 0, N - 2) ans = max(ans, A[i+1] - A[i]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from gap.cpp:4:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
gap.cpp:40:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   40 |         FOR  (i, 0, N - 2) ans = max(ans, A[i+1] - A[i]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from gap.cpp:4:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
gap.cpp:40:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |         FOR  (i, 0, N - 2) ans = max(ans, A[i+1] - A[i]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from gap.cpp:4:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
gap.cpp:40:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |         FOR  (i, 0, N - 2) ans = max(ans, A[i+1] - A[i]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~