Submission #303898

#TimeUsernameProblemLanguageResultExecution timeMemory
303898medmdgCarnival Tickets (IOI20_tickets)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; long long int fin(vector<vector<int> > a,int n,int m){ for(int i=0;i<n;i++){ sort(a[i].begin(),a[i].end()); } long long int ans=0; for(int i=0;i<n;i++){ long long int ff=a[i][(m)/2]; for(int j=0;j<m;j++){ ans+=(long long int)(abs(ff-a[i][j])); } } return ans; } long long int find_maximum(int k, vector<vector<int> > x){ int n=x.size(); int m=x[0].size(); if(m==1){ vector<vector<int> > ans(n); vector<vector<int> > answ(k); for(int i=0;i<n;i++){ ans[i].push_back(0); answ[0].push_back(x[i][0]); } allocate_tickets(ans); return fin(answ,k,n); } if(k==1){ vector<vector<int> > a(k); vector<vector<int> > b(n); for(int i=0;i<n;i++) for(int j=0;j<m;j++) b[i][j]=-1; int mi[n]; int ma[n]; for(int i=0;i<n;i++){ mi[i]=0; ma[i]=m-1; } vector<int> al; for(int i=0;i<n;i++){ al.push_back(mi[i]); al.push_back(ma[i]); } sort(al.begin(),al.end()); int mid=al[n]; for(int i=0;i<n;i++){ if(abs(mi[i]-mid)>abs(ma[i]-mid)){ a.push_back(mi[i]); b[i][0]=0; }else{ a.push_back(ma[i]); b[i][m-1]=0; } } allocate_tickets(b); return fin(a,k,n); } }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:51:34: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(int&)'
   51 |                 a.push_back(mi[i]);
      |                                  ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 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 '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 'int' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
tickets.cpp:54:34: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(int&)'
   54 |                 a.push_back(ma[i]);
      |                                  ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 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 '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 'int' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
tickets.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^