I don't know why the constraints are so bad!!
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 []\nclass Solution {\npublic:\n        vector<pair<int, int>>p = {{2, -1}, {2, 1}, {-2, -1}, {-2, 1}, {-1, 2}, {-1, -2}, {1, 2}, {1, -2}};\n        int dist[16][50][50];\n        int dp[1 << 16][16];\n        bool visited[50][50];\n\n\n        \n\n\n\n    int minMax(int curr, bool turn, int mask, vector<vector<int>>& positions, int &n) {\n        // cout<<curr<<endl;\n        if(mask == (1 << n) - 1)return dp[mask][curr] = 0;\n        if(dp[mask][curr] != -1)return dp[mask][curr];\n        int moves = turn ? INT_MIN : INT_MAX;\n\n        for(int i = 0; i < n; i++) {\n            if(mask & (1 << i))continue;\n            int masknew = mask | (1 << i);\n                // cout<<x.first<<" "<<x.second<<endl;\n            int a = positions[i][0];\n            int b = positions[i][1];\n            if(turn)\n                moves = max(moves, dist[curr][a][b] + \n            minMax(i, !turn, masknew, positions, n));\n            else moves = min(moves, dist[curr][a][b] + \n            minMax(i, !turn, masknew, positions, n));\n        }\n\n        return dp[mask][curr] = moves;\n    }\n    int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(NULL), cout.tie(NULL);\n        vector<int>a = {kx, ky};\n        positions.push_back(a);\n        // minMoves(positions);\n\n\n\n\n        queue<pair<int, int>>q;\n        memset(dist, 0, sizeof(dist));\n        int abc = 0;\n        for(auto w : positions) {    \n            memset(visited, 0, sizeof(visited));\n            // while(!q.empty())q.pop();\n            q.push({w[0], w[1]});\n            while(!q.empty()) {\n                auto x = q.front();q.pop();\n                int xi = x.first, yi = x.second;\n                if(xi < 0 || xi >= 50 || yi < 0 || yi >= 50)continue;\n                if(visited[xi][yi])continue;\n                visited[xi][yi] = true;\n                int currD = dist[abc][xi][yi];\n                // dist[abc][xi][yi] = y;\n\n\n                for(auto xx : p) {\n                    if(xi + xx.first < 0 || xi + xx.first >= 50 || yi + xx.second < 0 || yi + xx.second >= 50)continue;\n                    if(!visited[xi + xx.first][yi + xx.second])\n                        dist[abc][xi + xx.first][yi + xx.second] = currD + 1;\n                    q.push({xi + xx.first, yi + xx.second});\n                }\n            }\n            abc++;\n        }\n\n\n\n\n\n\n        memset(dp, -1, sizeof(dp));\n        int n = positions.size();\n        return minMax(n - 1, true, 0 | (1 << (n - 1)), positions, n);\n\n\n        return 0;\n    }\n};\n```
['C++']