제출 #301540

#제출 시각아이디문제언어결과실행 시간메모리
301540qiangbao카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <algorithm> #include <vector> #include "tickets.h" #define pb push_back using namespace std; typedef long long ll; typedef pair<ll, ll> pii; ll n, m, kk; vector<vector<ll> > a; ll beg[1501], endi[1501]; vector<pii> subt; ll ansval=0; vector<int> plamt; vector<vector<int> > ans; ll find_maximum(int kkk, vector<vector<int> > x) { ll i, j; n=x.size(), m=x[1].size(), kk=kkk; a=x; for(i=0;i<m;i++) plamt.pb(0); for(i=0;i<n;i++) ans.pb(plamt); for(i=0;i<n;i++) sort(a[i].begin(), a[i].end()); for(i=0;i<n;i++) endi[i]=m-1; for(i=0;i<kk;i++){ subt.clear(); for(j=0;j<n;j++){ ansval+=a[j][endi[j]]; subt.pb({a[j][endi[j]]+a[j][beg[j]], j}); } sort(subt.begin(), subt.end()); for(j=0;j<n/2;j++){ ansval-=subt[j].first; ans[j][beg[j]]=i; beg[subt[j].second]++; } for(j=n/2;j<n;j++){ ans[j][endi[j]]=i; endi[subt[j].second]--; } } allocate_tickets(ans); return ansval; }

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

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:28:7: error: no match for 'operator=' (operand types are 'std::vector<std::vector<long long int> >' and 'std::vector<std::vector<int> >')
   28 |     a=x;
      |       ^
In file included from /usr/include/c++/9/vector:72,
                 from tickets.cpp:3:
/usr/include/c++/9/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::vector<std::vector<long long int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/9/vector:67,
                 from tickets.cpp:3:
/usr/include/c++/9/bits/stl_vector.h:706:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:706:26: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::vector<std::vector<long long int> >&&'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:727:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  727 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:727:46: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::initializer_list<std::vector<long long int> >'
  727 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~