제출 #1062930

#제출 시각아이디문제언어결과실행 시간메모리
1062930Kipras카니발 티켓 (IOI20_tickets)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; #include "tickets.h" constexpr ll maxN = 1510; vector<pair<ll, ll>> colours[maxN]; vector<vector<int>> ans; long long find_maximum(int k, vector<vector<int>> a) { ll coloursN = a.size(); ll n = a[0].size(); ll res=0; for(int i = 0; i < coloursN; i++) { vector<ll> tmp; for(int x = 0; x < n; x++) { colours[i].push_back({a[i][x], x}); tmp.push_back({-1}); } ans.push_back(tmp); } for(int i = 0; i < coloursN; i++) sort(colours[i].begin(), colours[i].end()); priority_queue<pair<ll, pair<ll, pair<ll, ll>>>> q; for(int i = 0; i < coloursN; i++) { for(int x = 0; x < k; x++) { res+=colours[i][x].first; ans[i][colours[i][x].second]=x; q.push({-colours[i][x].first-colours[i][n-k+x].first, {i, {x, n-k+x}}}); } } for(int i = 0; i < k*(coloursN/2); i++) { pair<ll, pair<ll, pair<ll, ll>>> tmpPair = q.top(); q.pop(); res-= tmpPair.first; ll color = tmpPair.second.first; ll u = tmpPair.second.second.first; ll v = tmpPair.second.second.second; ans[color][v]=ans[color][u]; if(u!=v)ans[color][u]=-1; } allocate_tickets(ans); return res; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:22:26: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(std::vector<long long int>&)'
   22 |         ans.push_back(tmp);
      |                          ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const value_type&' {aka 'const std::vector<int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~