Language: C++

#include <iostream>
#include <iostream>
#include <algorithm>
#include <algorithm>


using namespace std;
using namespace std;




int n;
int n;
int a[100005][4];
int a[100005][4];
int dp[10005][4];
int dp[10005][4];


int go(int i, int prev) {
int go(int i, int prev) {
    if(i == n){
    if(i == n){
        return 0;
        return 0;
    }
    }
    if(dp[i][prev] != -1){
    if(dp[i][prev] != -1){
        return dp[i][prev];
        return dp[i][prev];
    }
    }
    int ans = 0;
    int ans = 0;


    if(prev == 0){
    if(prev == 0){
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][2] + go(i+1,2));
        ans = max(ans, a[i][2] + go(i+1,2));
        ans = max(ans, a[i][3] + go(i+1,3));
        ans = max(ans, a[i][3] + go(i+1,3));
    }else if(prev == 1){
    }else if(prev == 1){
        ans = max(ans, a[i][2] + go(i+1,2));
        ans = max(ans, a[i][2] + go(i+1,2));
        ans = max(ans, a[i][3] + go(i+1,3));
        ans = max(ans, a[i][3] + go(i+1,3));
    }else if (prev== 2){
    }else if (prev== 2){
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][3] + go(i+1,3));
        ans = max(ans, a[i][3] + go(i+1,3));
    }else if(prev == 3){
    }else if(prev == 3){
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][2] + go(i+1,2));
        ans = max(ans, a[i][2] + go(i+1,2));
    }
    }
    dp[i][prev] = ans;
    dp[i][prev] = ans;
    return dp[i][prev];
    return dp[i][prev];
}
}


int main(){
int main(){
    cin >> n;
    cin >> n;
	for (int i = 0; i < n; i++) {
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 3; j++) {
		for (int j = 1; j <= 3; j++) {
			cin >> a[i][j];
			cin >> a[i][j];
		}
		}
	}
	}
    memset(dp, -1, sizeof(dp));
    memset(dp, -1, sizeof(dp));


    int ans = go(0, 0);
    int ans = go(0, 0);
    cout << ans << endl; 
    cout << ans << endl; 
}
}


Compiler output:
a.cc:14:5: error: redefinition of 'int n'
   14 | int n;
      |     ^
a.cc:13:5: note: 'int n' previously declared here
   13 | int n;
      |     ^
a.cc:16:5: error: redefinition of 'int a [100005][4]'
   16 | int a[100005][4];
      |     ^
a.cc:15:5: note: 'int a [100005][4]' previously declared here
   15 | int a[100005][4];
      |     ^
a.cc:18:5: error: redefinition of 'int dp [10005][4]'
   18 | int dp[10005][4];
      |     ^~
a.cc:17:5: note: 'int dp [10005][4]' previously declared here
   17 | int dp[10005][4];
      |     ^~
a.cc: In function 'int go(int, int)':
a.cc:22:25: error: a function-definition is not allowed here before '{' token
   22 | int go(int i, int prev) {
      |                         ^
a.cc:72:1: warning: no return statement in function returning non-void [-Wreturn-type]
   72 | }
      | ^
a.cc: In function 'int main()':
a.cc:76:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   76 | int main(){
      |         ^~
a.cc:76:9: note: remove parentheses to default-initialize a variable
   76 | int main(){
      |         ^~
      |         --
a.cc:76:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:76:11: error: a function-definition is not allowed here before '{' token
   76 | int main(){
      |           ^