제출 #592410

#제출 시각아이디문제언어결과실행 시간메모리
592410ogibogi2004카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include "tickets.h" #include <vector> #include<bits/stdc++.h> using namespace std; #define ll long long long long find_maximum(int k, vector<vector<int>> x) { //cout<<"?\n"; ll n = x.size(); ll m = x[0].size(); vector<vector<int>> answer; vector<ll>smallest[n]; for(ll i=0;i<n;i++) { smallest[i]=x[i]; sort(smallest[i].begin(),smallest[i].end()); } ll use[n][m]; memset(use,-1,sizeof(use)); ll dp[n][n*k]; ll hist[n][n*k]; bool c[n][n*k]; memset(c,0,sizeof(c)); ll sum=0; for(ll j=0;j<k;j++)sum-=smallest[0][j]; dp[0][k]=sum;c[0][k]=1; hist[0][k]=k; for(ll j=k-1;j>=0;j--) { sum+=smallest[0][j]; sum+=smallest[0][smallest[0].size()-(k-j)]; dp[0][j]=sum;c[0][j]=1; hist[0][j]=j; } //cout<<"eho1\n"; for(ll i=1;i<n;i++) { sum=0; for(ll j=0;j<k;j++)sum-=smallest[i][j]; for(ll prv=0;prv+k<=n*k/2;prv++) { if(!c[i-1][prv])continue; if(c[i][prv+k]==0) { dp[i][prv+k]=dp[i-1][prv]+sum; c[i][prv+k]=1; hist[i][prv+k]=k; } else { if(dp[i-1][prv]+sum>dp[i][prv+k]) { dp[i][prv+k]=dp[i-1][prv]+sum; hist[i][prv+k]=k; } } } for(ll j=k-1;j>=0;j--) { sum+=smallest[i][j]; sum+=smallest[i][smallest[i].size()-(k-j)]; for(ll prv=0;prv+j<=n*k/2;prv++) { if(!c[i-1][prv])continue; if(c[i][prv+j]==0) { dp[i][prv+j]=dp[i-1][prv]+sum; hist[i][prv+j]=j; c[i][prv+j]=1; } else { if(dp[i-1][prv]+sum>dp[i][prv+j]) { dp[i][prv+j]=dp[i-1][prv]+sum; hist[i][prv+j]=j; } } } } } //cout<<"eho2\n"; ll t=n*k/2; vector<ll>small[n]; vector<ll>large[n]; for(ll j=n-1;j>=0;j--) { //cout<<j<<" "<<t<<endl; ll cnts=hist[j][t]; //cout<<" "<<cnts<<endl; vector<pair<ll,ll> >smallest1; for(ll i=0;i<m;i++) { smallest1.push_back({x[j][i],i}); } sort(smallest1.begin(),smallest1.end()); for(ll i=0;i<cnts;i++) { small[j].push_back(smallest1[i].second); } for(ll i=1;i<=k-cnts;i++) { large[j].push_back(smallest1[m-i].second); } t-=cnts; } //cout<<"eho3\n"; //cout<<dp[n-1][n*k/2]<<endl; for(ll j=0;j<k;j++) { //cout<<j<<endl; vector<pair<ll,ll> >sizes; for(ll i=0;i<n;i++) { sizes.push_back({small[i].size(),i}); } sort(sizes.rbegin(),sizes.rend()); for(ll i=0;i<sizes.size();i++) { //cout<< " "<<i<<endl; if(i<n/2) { //cout<<" "<<small[sizes[i].second].size()<<endl; use[sizes[i].second][small[sizes[i].second].back()]=j; small[sizes[i].second].pop_back(); } else { use[sizes[i].second][large[sizes[i].second].back()]=j; large[sizes[i].second].pop_back(); } } } //cout<<"eho4\n"; for(ll i=0;i<n;i++) { //cout<<i<<endl; vector<int>v; for(ll j=0;j<m;j++) { v.push_back(use[i][j]); } answer.push_back(v); } allocate_tickets(answer); return dp[n-1][n*k/2]; } /* 2 3 2 0 2 5 1 1 3 */

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:14:24: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   14 |         smallest[i]=x[i];
      |                        ^
In file included from /usr/include/c++/10/vector:72,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
tickets.cpp:118:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |         for(ll i=0;i<sizes.size();i++)
      |                    ~^~~~~~~~~~~~~