DP With Bitmask
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n#define ll long long\n#define vll vector<ll>\n#define vvll vector<vll>\nclass Solution {\npublic:\n    int maxScore(vector<vector<int>>& grid) {\n        ll n=grid.size(), m=grid[0].size();\n\n        map<ll, vll> mp;\n        for(ll i=0; i<n; i++){\n            for(ll j=0; j<m; j++){\n                mp[grid[i][j]].push_back(i);\n            }\n        }\n        int dp[101][1<<n];\n        memset(dp, -1, sizeof(dp));\n        function<ll(ll, ll)> f=[&](ll num, ll msk)->ll{\n            if(num<=0) return 0;\n            ll mx=0;\n            if(dp[num][msk]!=-1) return dp[num][msk];\n            mx=f(num-1, msk);\n            for(auto i: mp[num]){\n                if(msk&(1<<i)) continue;\n                mx=max(mx, num+f(num-1, msk|(1<<i)));\n            }\n            return dp[num][msk]= mx;\n        };\n\n        return f(100, 0);\n    }\n};\n```
['C++']