제출 #303696

#제출 시각아이디문제언어결과실행 시간메모리
303696junseo비스킷 담기 (IOI20_biscuits)C++17
컴파일 에러
0 ms0 KiB
#include "biscuits.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define all(v) (v).begin(), (v).end() #define rmin(r, x) r = min(r, x) #define rmax(r, x) r = max(r, x) #define ends ' ' #define endl '\n' #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #pragma GCC optimize("O3") #pragma GCC target("avx,avx2") using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int maxk = 65; int k; ll s[maxk]; inline long long count_tastiness(long long x, std::vector<long long> a) { k = a.size(); a.resize(maxk); s[0] = a[0]; for(int i = 1; i <= 60; ++i) s[i] = s[i - 1] + (1LL << i) * a[i]; vector<ll> ans; ans.eb(0); for(int i = 0; (1LL << i) <= s[60] && i <= 60; ++i) { int st = 0, ed = ans.size() - 1, r = -1; while(st <= ed) { int mid = st + ed >> 1; if(s[i] >= (__int128)(ans[mid] + (1LL << i)) * x) { r = mid; st = mid + 1; } else ed = mid - 1; } // for(int j = 0; j <= r; ++j) { // ans.eb(ans[j] + (1LL << i)); // } if(r >= 0) ans.insert(ans.begin(), ans.begin() + r + 1); int t = ans.size(); for(int j = 1; j <= r; ++j) ans[t - j] += (1LL << i); } assert(ans.size() <= 2e5); return ans.size(); }

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

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:35:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |    int mid = st + ed >> 1;
      |              ~~~^~~~
biscuits.cpp:45:57: error: no matching function for call to 'std::vector<long long int>::insert(std::vector<long long int>::iterator, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >)'
   45 |   if(r >= 0) ans.insert(ans.begin(), ans.begin() + r + 1);
      |                                                         ^
In file included from /usr/include/c++/9/vector:72,
                 from biscuits.h:1,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/vector.tcc:130:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = long long int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const long long int*; std::vector<_Tp, _Alloc>::value_type = long long int]'
  130 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/vector.tcc:132:57: note:   no known conversion for argument 2 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'const value_type&' {aka 'const long long int&'}
  132 |     insert(const_iterator __position, const value_type& __x)
      |                                       ~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/9/vector:67,
                 from biscuits.h:1,
                 from biscuits.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1290:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = long long int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const long long int*; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1290 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:1290:54: note:   no known conversion for argument 2 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'std::vector<long long int>::value_type&&' {aka 'long long int&&'}
 1290 |       insert(const_iterator __position, value_type&& __x)
      |                                         ~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1307:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = long long int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const long long int*]'
 1307 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:1307:70: note:   no known conversion for argument 2 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'std::initializer_list<long long int>'
 1307 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1332:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = long long int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const long long int*; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1332 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:1332:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/9/bits/stl_vector.h:1376:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = long long int; _Alloc = std::allocator<long long int>]'
 1376 |  insert(const_iterator __position, _InputIterator __first,
      |  ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:1376:2: note:   template argument deduction/substitution failed:
biscuits.cpp:45:57: note:   candidate expects 3 arguments, 2 provided
   45 |   if(r >= 0) ans.insert(ans.begin(), ans.begin() + r + 1);
      |                                                         ^