C++ concise code | using next_permutation | O(n*(n*m)*n!)
\nclass Solution {\npublic:\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\n        int n = students.size();\n     
```\nclass Solution {\npublic:\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\n        int n = students.size();\n        int m = students[0].size();\n        vector<int>pos;\n        \n        for(int i = 0; i<n;i++){\n            pos.push_back(i);\n        }\n        \n        int ans = 0;\n        \n        do{\n            int cur = 0;\n            for(int i = 0; i<n;i++){\n                for(int j = 0; j<m; j++){\n                    if(students[i][j]==mentors[pos[i]][j])cur++;\n                }\n            }\n            ans = max(cur,ans);\n        }while(next_permutation(pos.begin(), pos.end()));\n        return ans;\n    }\n};``\n```
[]