Submission #309810

#TimeUsernameProblemLanguageResultExecution timeMemory
309810aZvezdaCarnival Tickets (IOI20_tickets)C++14
Compilation error
0 ms0 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" typedef long long ll; typedef long double ld; typedef unsigned long long ull; template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } const ll mod = 1e9 + 7; template<class T> inline void fix(T &x) {if(labs(x) >= mod) {x %= mod;} if(x < 0) {x += mod;}} #define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl long long find_maximum(int k, std::vector<std::vector<int>> x) { ll n = x.size(); ll m = x[0].size(); std::vector<std::vector<int> > answer; vector<vector<pair<ll, ll> > > pr; priority_queue<pair<ll, ll> > pq; vector<ll> got; got.resize(n); ll ans = 0; for (ll i = 0; i < n; i++) { vector<ll> row(m); for(ll j = 0; j < m; j++) { row[j] = -1; } for(ll j = m - k; j < m; j ++) { ans += x[i][j]; } pq.push({-x[i][0] - x[i][m - k], i}); answer.push_back(row); } ll iter = n * k / 2; for(ll i = 0; i < iter; i ++) { auto curr = pq.top(); pq.pop(); ans += curr.first; got[curr.second] ++; if(got[curr.second] < k) { pq.push({-x[curr.second][got[curr.second]] - x[curr.second][m - k + got[curr.second]], curr.second}); } } ll cnt = 0; for(ll i = 0; i < n; i ++) { for(ll j = 0; j < got[i]; j ++) { answer[i][j] = (cnt + j) % k; } cnt += got[i]; ll group = cnt; for(ll j = m - k + got[i]; j < m; j ++) { answer[i][j] = group % k; group ++; } } allocate_tickets(answer); return ans; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:34:23: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(std::vector<long long int>&)'
   34 |   answer.push_back(row);
      |                       ^
In file included from /usr/include/c++/9/vector:67,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184: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>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const value_type&' {aka 'const std::vector<int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200: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>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200: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>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~