C++ | DP + Brute Force
Code
# Code
```cpp []
#define ll long long
class Solution {
public:
    ll n,dp[(ll)1e5+5][4][4], ok[6]{1,2,3,1,2,3};
    ll rec(int i ,int prev1 ,int prev2 ,int n, vector<vector<int>>&x){
        if(i == n / 2)return 0;

        ll & ret = dp[i][prev1][prev2];
        if(~ret)return ret;

        ret = 1e18;

        for(int j = 0 ; j < 6; j++)
            for(int k = 0 ;k < 6; k++)
                if(ok[j] != ok[k] && ok[j] != prev1 && ok[k] != prev2)
                    ret = min(ret,x[i][ok[j] - 1] + x[n - 1 - i][ok[k] - 1] + rec(i + 1 ,ok[j] , ok[k], n, x));
        return ret;
    }
    long long minCost(int n, vector<vector<int>>& cost) {
        for(int i=0; i <= n / 2 ;i++)
            for(int j=0; j < 4;j++)
                for(int k=0 ;k < 4;k++)dp[i][j][k]=-1;

        return rec(0, 0, 0, n,cost);
    }
};
```
['Dynamic Programming', 'C++']