제출 #1315926

#제출 시각아이디문제언어결과실행 시간메모리
1315926ezzzay축제 (IOI25_festival)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second std::vector<int> max_coupons(int A, std::vector<int> P, std::vector<int> T) { int N=P.size(); vector<vector<pair<int,int>>> v(5,vector<pair<int,int>>(N+5)); for(int i=0;i<N;i++){ v[T[i]].pb({P[i],i}); } for(int i=1;i<=4;i++){ sort(v[i].begin(),v[i].end()); } vector<int>ans; vector<int>idx(5); bool u=1; while(u){ bool h=0; for(int i=4;i>=1;i--){ if(idx[i]==v[idx].size())continue; if(v[i][idx[i]].ff<=A){ A-=v[i][idx[i]].ff; A*=i; ans.pb(v[idx[i]].ss); idx[i]++; h=1; break; } } u=h; } return ans; }

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

festival.cpp: In function 'std::vector<int> max_coupons(int, std::vector<int>, std::vector<int>)':
festival.cpp:22:25: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<std::pair<int, int> > >' and 'std::vector<int>')
   22 |             if(idx[i]==v[idx].size())continue;
      |                         ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from festival.cpp:1:
/usr/include/c++/13/bits/stl_vector.h:1126:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; reference = std::vector<std::pair<int, int> >&; size_type = long unsigned int]'
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1126:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'}
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1145:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; const_reference = const std::vector<std::pair<int, int> >&; size_type = long unsigned int]'
 1145 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1145:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'}
 1145 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
festival.cpp:5:12: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'second'
    5 | #define ss second
      |            ^~~~~~
festival.cpp:26:34: note: in expansion of macro 'ss'
   26 |                 ans.pb(v[idx[i]].ss);
      |                                  ^~