C++ || Accepted || Memorization Solution
Code

# Code
```cpp []
class Solution {
public:
    
    long long mem[50010][4][4];
    long long f(int i,int p1,int p2,int n, vector<vector<int>> & cost){
          if(i==(n/2)) return 0;

          long long ans = 1e18;
          if(mem[i][p1+1][p2+1] != -1) return mem[i][p1+1][p2+1];
          //color 0
          if(p1 != 0){
            if(p2 != 1) ans = min(ans, cost[i][0] + cost[n-i-1][1] + f(i+1,0,1,n,cost));
            if(p2 != 2) ans = min(ans, cost[i][0] + cost[n-i-1][2] + f(i+1,0,2,n,cost));
          }
          //color 1
          if(p1 != 1){
            if(p2 != 0) ans = min(ans, cost[i][1] + cost[n-i-1][0] + f(i+1,1,0,n,cost));
            if(p2 != 2) ans = min(ans, cost[i][1] + cost[n-i-1][2] + f(i+1,1,2,n,cost));
          }
          //color 2
          if(p1 != 2){
            if(p2 != 0) ans = min(ans, cost[i][2] + cost[n-i-1][0] + f(i+1,2,0,n,cost));
            if(p2 != 1) ans = min(ans, cost[i][2] + cost[n-i-1][1] + f(i+1,2,1,n,cost));
          }
          return mem[i][p1+1][p2+1] = ans;
    }
    
    long long minCost(int n, vector<vector<int>>& cost) {
        memset(mem,-1,sizeof(mem));
        return f(0,-1,-1,n,cost);
    }
};
```
['Dynamic Programming', 'Recursion', 'Memoization', 'C++']