Language: C++

int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
{
    
    if(i>=n)
        return 0;
    if(prev == 0)
    {
        int n1 = a[i] + func(a,b,c,i+1,n,1,dp);
        int n2 = b[i] + func(a,b,c,i+1,n,2,dp);
        int n3 = c[i] + func(a,b,c,i+1,n,3,dp); 
        return max(n1,max(n2,n3));       
    }

    if(dp[i][prev-1])
    {
        if(prev == 1)
        {
            int n1 = b[i] + func(a,b,c,i+1,n,2,dp);
            int n2 = c[i] + func(a,b,c,i+1,n,3,dp);
            dp[i][prev-1] = max(n1,n2);
        }
        if(prev == 2)
        {
            int n1 = a[i] + func(a,b,c,i+1,n,1,dp);
            int n2 = c[i] + func(a,b,c,i+1,n,3,dp);
            dp[i][prev-1] = max(n1,n2);
        }
        if(prev == 3)
        {
            int n1 = a[i] + func(a,b,c,i+1,n,1,dp);
            int n2 = b[i] + func(a,b,c,i+1,n,2,dp);
            dp[i][prev-1] = max(n1,n2);
        }
    }
    return dp[i][prev-1];

}

int main()
{
    int n{};
    cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    std::vector<vector<int>> dp(n,vector<int>(3,-1));
    cout<<func(a,b,c,0,n,0,dp);
    return 0;
}

Compiler output:
a.cc:1:10: error: 'vector' was not declared in this scope
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |          ^~~~~~
a.cc:1:17: error: expected primary-expression before 'int'
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                 ^~~
a.cc:1:26: error: 'vector' was not declared in this scope
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                          ^~~~~~
a.cc:1:33: error: expected primary-expression before 'int'
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                 ^~~
a.cc:1:42: error: 'vector' was not declared in this scope
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                          ^~~~~~
a.cc:1:49: error: expected primary-expression before 'int'
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                                 ^~~
a.cc:1:57: error: expected primary-expression before 'int'
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                                         ^~~
a.cc:1:63: error: expected primary-expression before 'int'
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                                               ^~~
a.cc:1:69: error: expected primary-expression before 'int'
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                                                     ^~~
a.cc:1:83: error: 'vector' is not a member of 'std'
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                                                                   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
a.cc:1:90: error: 'vector' was not declared in this scope
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                                                                          ^~~~~~
a.cc:1:97: error: expected primary-expression before 'int'
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                                                                                 ^~~
a.cc:1:106: error: expression list treated as compound expression in initializer [-fpermissive]
    1 | int func(vector<int> &a, vector<int> &b, vector<int> &c,int i,int n,int prev,std::vector<vector<int>> &dp)
      |                                                                                                          ^
a.cc: In function 'int main()':
a.cc:42:5: error: 'cin' was not declared in this scope
   42 |     cin>>n;
      |     ^~~
a.cc:43:5: error: 'vector' was not declared in this scope
   43 |     vector<int> a(n),b(n),c(n);
      |     ^~~~~~
a.cc:43:12: error: expected primary-expression before 'int'
   43 |     vector<int> a(n),b(n),c(n);
      |            ^~~
a.cc:45:14: error: 'a' was not declared in this scope
   45 |         cin>>a[i]>>b[i]>>c[i];
      |              ^
a.cc:45:20: error: 'b' was not declared in this scope
   45 |         cin>>a[i]>>b[i]>>c[i];
      |                    ^
a.cc:45:26: error: 'c' was not declared in this scope
   45 |         cin>>a[i]>>b[i]>>c[i];
      |                          ^
a.cc:46:10: error: 'vector' is not a member of 'std'
   46 |     std::vector<vector<int>> dp(n,vector<int>(3,-1));
      |          ^~~~~~
a.cc:46:10: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:46:24: error: expected primary-expression before 'int'
   46 |     std::vector<vector<int>> dp(n,vector<int>(3,-1));
      |                        ^~~
a.cc:47:5: error: 'cout' was not declared in this scope
   47 |     cout<<func(a,b,c,0,n,0,dp);
      |     ^~~~
a.cc:47:16: error: 'a' was not declared in this scope
   47 |     cout<<func(a,b,c,0,n,0,dp);
      |                ^
a.cc:47:18: error: 'b' was not declared in this scope
   47 |     cout<<func(a,b,c,0,n,0,dp);
      |                  ^
a.cc:47:20: error: 'c' was not declared in this scope
   47 |     cout<<func(a,b,c,0,n,0,dp);
      |                    ^
a.cc:47:28: error: 'dp' was not declared in this scope
   47 |     cout<<func(a,b,c,0,n,0,dp);
      |                            ^~
a.cc:47:30: error: 'func' cannot be used as a function
   47 |     cout<<func(a,b,c,0,n,0,dp);
      |                              ^