{ string, index} in map dp
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    long long minCost(int n, vector<vector<int>>& cost) {
        map<pair<string,long long>,long long> mp;
        for(int i=0;i<n/2;i++){
            mp[{"AB",i}] = min({mp[{"BA",i-1}] + cost[i][1] + cost[n-1-i][0] ,mp[{"BC",i-1}] + cost[i][1] + cost[n-1-i][2] ,mp[{"CA",i-1}] + cost[i][2] + cost[n-1-i][0]}); 
            mp[{"BC",i}] = min({mp[{"AB",i-1}] + cost[i][0] + cost[n-1-i][1] ,mp[{"CB",i-1}] + cost[i][2] + cost[n-1-i][1] ,mp[{"CA",i-1}] + cost[i][2] + cost[n-1-i][0]}); 
            mp[{"CA",i}] = min({mp[{"AB",i-1}] + cost[i][0] + cost[n-1-i][1] ,mp[{"AC",i-1}] + cost[i][0] + cost[n-1-i][2] ,mp[{"BC",i-1}] + cost[i][1] + cost[n-1-i][2]}); 
            mp[{"BA",i}] = min({mp[{"AB",i-1}] + cost[i][0] + cost[n-1-i][1] ,mp[{"AC",i-1}] + cost[i][0] + cost[n-1-i][2] ,mp[{"CB",i-1}] + cost[i][2] + cost[n-1-i][1]}); 
            mp[{"CB",i}] = min({mp[{"AC",i-1}] + cost[i][0] + cost[n-1-i][2] ,mp[{"BA",i-1}] + cost[i][1] + cost[n-1-i][0] ,mp[{"BC",i-1}] + cost[i][1] + cost[n-1-i][2]}); 
            mp[{"AC",i}] = min({mp[{"BA",i-1}] + cost[i][1] + cost[n-1-i][0] ,mp[{"CA",i-1}] + cost[i][2] + cost[n-1-i][0] ,mp[{"CB",i-1}] + cost[i][2] + cost[n-1-i][1]}); 
        }
        long long a = min({mp[{"AB",n/2-1}], mp[{"BC",n/2-1}], mp[{"CA",n/2-1}], mp[{"BA",n/2-1}], mp[{"CB",n/2-1}], mp[{"AC",n/2-1}]});
        return a;
    }
};
```
['C++']