제출 #319786

#제출 시각아이디문제언어결과실행 시간메모리
319786akobi카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include "tickets.h" #include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define mp make_pair using namespace std; ll n,m,anss,c,cc; vector< vector<int> > ans; vector<ll> temp,fix; set< pair<ll,ll> >s; pair<ll,ll> t; ll find_maximum(ll k, vector< vector<ll> > x) { n=x.size(); m=x[0].size(); for (int i=0; i<m; i++) temp.pb(-1); for (int i=0; i<n; i++) ans.pb(temp); for (int i=0; i<n; i++) fix.pb(0); for (int i=0; i<n; i++) { for (int j=m-k; j<m; j++) anss+=x[i][j]; s.insert( mp( x[i][0]+x[i][m-k] , i) ); } for (int c=0; c<k*n/2; c++) { t=*s.begin(); s.erase(*s.begin()); anss-=t.F; fix[t.S]++; if (fix[t.S]<k) s.insert( mp( x[t.S][fix[t.S]] + x[t.S][m-k+fix[t.S]] , t.S ) ); } for (int i=0; i<n; i++) { for (int j=0; j<fix[i]; j++) { ans[i][j]=c; c++; c%=k; } cc=c; for (int j=m-k+fix[i]; j<m; j++) { ans[i][j]=cc; cc++; cc%=k; } } allocate_tickets(ans); return anss; }

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

tickets.cpp: In function 'long long int find_maximum(long long int, std::vector<std::vector<long long int> >)':
tickets.cpp:21:20: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(std::vector<long long int>&)'
   21 |         ans.pb(temp);
      |                    ^
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)
      |                 ~~~~~~~~~~~~~^~~