[c++]  16ms DP
This is a pretty good problem,  I see the mask & simulation solution, DP solution,  And greedy!\nVery satisfiled!\n\n\n\nstruct Value {\n    int mn = INT_MAX;\n
This is a pretty good problem,  I see the mask & simulation solution, DP solution,  And greedy!\nVery satisfiled!\n\n```\n\nstruct Value {\n    int mn = INT_MAX;\n    int mx = INT_MIN;\n    Value(int a, int b)\n    {\n        mn = a;\n        mx = b;\n    }\n    Value()\n    {}\n    \n    void update(Value& v)\n    {\n        mn = std::min(v.mn + 1, mn);\n        mx = std::max(v.mx + 1, mx);\n    }\n};\nclass Solution {\npublic:\n    // min\n    vector<vector<vector<::Value>>> dp;\n    // max\n    // a left b right\n    ::Value dfs(int a, int b, int n)\n    {\n        if (a > b) {\n            swap(a, b);\n        }\n        \n        if ((a == b) || (n <= 2))\n        {\n            dp[n][a][b] = ::Value(1, 1);\n             cout << a << "," << b << ":" << n << endl;\n            cout << dp[n][a][b].mn << "," << dp[n][a][b].mx << endl;\n            return dp[n][a][b];\n        }\n        if (dp[n][a][b].mn != INT_MAX)\n        {\n            cout << a << "," << b << ":" << n << endl;\n            cout << dp[n][a][b].mn << "," << dp[n][a][b].mx << endl;\n            return dp[n][a][b];\n        }\n        \n        int m = (n / 2) + (((n%2) == 0) ? 0 : 1);\n        ::Value best;\n        if (b <= m)\n        {\n            \n            for (int i = 1; i <= a; i++)\n            {\n                int x = a - i;\n                int y = b - a;\n                for (int j = x + 1; j <= x + y; j++)\n                {\n                    auto cur = dfs(i, j, m);\n                    best.update(cur);\n                }\n            }\n        }\n        else\n        {\n\n            for (int i = 1; i <= a; i++)\n            {\n                int x = a - i;\n                \n                int b1 = n + 1 - b;\n                int y = b1 - a;\n                int z = m - b1;\n                \n                for (int j = x + 1 + z; j <= x + y + z; j++)\n                {\n                    //cout << "next:" << i << "," << j << ","<< x << "," << z << "," << m << "," << b1 << "," << a << "," << b << "," << n << endl;\n                    auto cur = dfs(i, j, m);\n                    best.update(cur);\n                }\n            }\n        }\n        dp[n][a][b] = best;\n        \n        cout << a << "," << b << ":" << m << "," <<  n << endl;\n        cout << best.mn << "," << best.mx << endl;\n        return best;\n    }\n    \n    vector<int> earliestAndLatest(int n1, int firstPlayer, int secondPlayer) {\n        int n = n1 + 1;\n        dp = vector<vector<vector<::Value>>>(n, vector<vector<::Value>>(n, vector<::Value>(n)));\n        auto ans = dfs(firstPlayer, n - secondPlayer, n1);\n        vector<int> v = {ans.mn, ans.mx};\n        return v;\n    }\n};\n```
[]