Language: C++


#include <iostream>
#include<vector>
using namespace std;
struct data
{
  int a,b,c;
};
int VacationKeMaz(int n, vector<data>& v)
{ 
    int dp[n+1][3];
    dp[1][0]=v[1].a;
    dp[1][1]=v[1].b;
    dp[1][2]=v[1].c;
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=v[i].a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=v[i].b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=v[i].c+max(dp[i-1][0],dp[i-1][1]);
    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main() {
    int n;
    cin>>n;
    vector<data> v(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i].a;
        cin>>v[i].b;
        cin>>v[i].c;
    }
    cout<<VacationKeMaz(n,v);
}


Compiler output:
a.cc:9:37: error: template argument 1 is invalid
    9 | int VacationKeMaz(int n, vector<data>& v)
      |                                     ^
a.cc:9:37: error: template argument 2 is invalid
a.cc:9:37: error: template argument 1 is invalid
a.cc:9:37: error: template argument 2 is invalid
a.cc:9:37: error: template argument 1 is invalid
a.cc:9:37: error: template argument 2 is invalid
a.cc:9:26: error: invalid template-id
    9 | int VacationKeMaz(int n, vector<data>& v)
      |                          ^~~~~~
a.cc:9:33: error: reference to 'data' is ambiguous
    9 | int VacationKeMaz(int n, vector<data>& v)
      |                                 ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:5:8: note:                 'struct data'
    5 | struct data
      |        ^~~~
a.cc:9:26: error: missing template argument list after 'std::vector'; template placeholder not permitted in parameter
    9 | int VacationKeMaz(int n, vector<data>& v)
      |                          ^~~~~~
      |                                <>
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'template<class _Tp, class _Alloc> class std::vector' declared here
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc: In function 'int VacationKeMaz(...)':
a.cc:12:14: error: 'v' was not declared in this scope
   12 |     dp[1][0]=v[1].a;
      |              ^
a.cc: In function 'int main()':
a.cc:26:16: error: template argument 1 is invalid
   26 |     vector<data> v(n+1);
      |                ^
a.cc:26:16: error: template argument 2 is invalid
a.cc:29:15: error: invalid types 'int[int]' for array subscript
   29 |         cin>>v[i].a;
      |               ^
a.cc:30:15: error: invalid types 'int[int]' for array subscript
   30 |         cin>>v[i].b;
      |               ^
a.cc:31:15: error: invalid types 'int[int]' for array subscript
   31 |         cin>>v[i].c;
      |               ^