제출 #1099351

#제출 시각아이디문제언어결과실행 시간메모리
1099351ZflopCircle Passing (EGOI24_circlepassing)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(),x.end() #define sor(x) sort(all(x)) #define pi pair<int,int> #define vi vector<int> #define int ll #define pb push_back int N,M,Q; void solve() { cin >> N >> M >> Q; vi bestfriend{0}; for (int i = 0; i < M;++i) { int b = 0; cin >> b; bestfriend.pb(b); bestfriend.pb(b + N); } auto Do = [&] (int a,int b) { if (a > 2 * N) a -= 2 * N; if (a > b) swap(a,b); int ans = (int)1e9; ans = b - a; ans = min(ans,a + 2 * N - b); return ans; }; while(Q--) { int a,b; cin >> a >> b; if (a > b) swap(a,b); int ans = (int)1e9; ans = b - a; ans = min(ans,a + 2 * N - b); int l = 1,r = bestfriend.size() - 1; int p = -1; while (l <= r) { int mid = (l + r) / 2; if (bestfriend[mid] <= a) { p = mid; l = mid + 1; } else { r = mid - 1; } } ans = min({ans,Do(bestfriend[p],b) + a - bestfriend[p],Do(bestfriend[p + 1]) + bestfriend[p + 1] - a}); ans = min(ans,Do(N + bestfriend[p],b) + a - bestfriend[p] + 1); ans = min(ans,Do(N + bestfriend[p + 1],b) + bestfriend[p + 1] - a + 1); cout << ans << '\n'; } } main(){ solve(); }

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

Main.cpp: In function 'void solve()':
Main.cpp:50:84: error: no match for call to '(solve()::<lambda(long long int, long long int)>) (__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   50 |         ans = min({ans,Do(bestfriend[p],b) + a - bestfriend[p],Do(bestfriend[p + 1]) + bestfriend[p + 1] - a});
      |                                                                                    ^
Main.cpp:21:15: note: candidate: 'solve()::<lambda(long long int, long long int)>'
   21 |     auto Do = [&] (int a,int b) {
      |               ^
Main.cpp:21:15: note:   candidate expects 2 arguments, 1 provided
Main.cpp:50:110: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   50 |         ans = min({ans,Do(bestfriend[p],b) + a - bestfriend[p],Do(bestfriend[p + 1]) + bestfriend[p + 1] - a});
      |                                                                                                              ^
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 Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:50:110: note:   candidate expects 2 arguments, 1 provided
   50 |         ans = min({ans,Do(bestfriend[p],b) + a - bestfriend[p],Do(bestfriend[p + 1]) + bestfriend[p + 1] - a});
      |                                                                                                              ^
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 Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:50:110: note:   candidate expects 3 arguments, 1 provided
   50 |         ans = min({ans,Do(bestfriend[p],b) + a - bestfriend[p],Do(bestfriend[p + 1]) + bestfriend[p + 1] - a});
      |                                                                                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp: At global scope:
Main.cpp:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main(){
      | ^~~~