C++ brute force
\nclass Solution {\n    int earliest(int n, int x, int y, vector<vector<vector<int>>> &dp) {\n        int& r = dp[n][x][y];\n        if (r >= 0) {\n            
```\nclass Solution {\n    int earliest(int n, int x, int y, vector<vector<vector<int>>> &dp) {\n        int& r = dp[n][x][y];\n        if (r >= 0) {\n            return r;\n        }\n        if (x + y == n - 1) {\n            return r = 1;\n        }\n        int round = n >> 1;\n        if (n & 1) {\n            const int mid = round;\n            if (x != mid) {\n                --round;\n            }\n            if (y != mid) {\n                --round;\n            }\n        }\n        r = n;\n        for (int mask = (1 << round) - 1; mask >= 0; --mask) {\n            int winners = (n & 1) ? (1 << (n >> 1)) : 0;\n            for (int i = 0, j = n - 1, ind = 0; i < j; ++i, --j) {\n                if (i == x || i == y) {\n                    winners |= 1 << i;\n                } else if (j == x || j == y) {\n                    winners |= 1 << j;\n                } else if (mask & (1 << (ind++))) {\n                    winners |= 1 << i;\n                } else {\n                    winners |= 1 << j;\n                }\n            }\n            int xx = 0, yy = 0, m = 0;\n            for (int i = 0; i < n; ++i) {\n                if (winners & (1 << i)) {\n                    if (i == x) {\n                        xx = m;\n                    } else if (i == y) {\n                        yy = m;\n                    }\n                    ++m;\n                }\n            }\n            r = min(r, earliest(m, xx, yy, dp));\n        }\n        return ++r;\n    }\n    \n    int latest(int n, int x, int y, vector<vector<vector<int>>> &dp) {\n        int& r = dp[n][x][y];\n        if (r >= 0) {\n            return r;\n        }\n        if (x + y == n - 1) {\n            return r = 1;\n        }\n        int round = n >> 1;\n        if (n & 1) {\n            const int mid = round;\n            if (x != mid) {\n                --round;\n            }\n            if (y != mid) {\n                --round;\n            }\n        }\n        r = 0;\n        for (int mask = (1 << round) - 1; mask >= 0; --mask) {\n            int winners = (n & 1) ? (1 << (n >> 1)) : 0;\n            for (int i = 0, j = n - 1, ind = 0; i < j; ++i, --j) {\n                 if (i == x || i == y) {\n                    winners |= 1 << i;\n                } else if (j == x || j == y) {\n                    winners |= 1 << j;\n                } else if (mask & (1 << (ind++))) {\n                    winners |= 1 << i;\n                } else {\n                    winners |= 1 << j;\n                }\n            }\n            int xx = 0, yy = 0, m = 0;\n            for (int i = 0; i < n; ++i) {\n                if (winners & (1 << i)) {\n                    if (i == x) {\n                        xx = m;\n                    } else if (i == y) {\n                        yy = m;\n                    }\n                    ++m;\n                }\n            }\n            r = max(r, latest(m, xx, yy, dp));\n        }\n        return ++r;\n    \n    }\npublic:\n    vector<int> earliestAndLatest(int n, int firstPlayer, int secondPlayer) {\n        vector<vector<vector<int>>> a(n + 1, vector<vector<int>>(n, vector<int>(n, -1))), b(n + 1, vector<vector<int>>(n, vector<int>(n, -1)));\n        --firstPlayer;\n        --secondPlayer;\n        return {earliest(n, firstPlayer, secondPlayer, a), latest(n, firstPlayer, secondPlayer, b)};\n        \n    }\n};\n```
[]