[C++]dfs and memorize dp
2<=n<=28,so we can use int as the status of players ,\nuse dp to memorize answers of each status for avoiding duplicated calculation\n\nunordered_set<int> super
2<=n<=28,so we can use int as the status of players ,\nuse dp to memorize answers of each status for avoiding duplicated calculation\n```\nunordered_set<int> super;\nunordered_map<int, unordered_set<int>> mp;\nint mn = INT_MAX, mx = INT_MIN, nn;\n\nvoid dfs(int s, int level) {\n//    cout << "hex:" << "i = " << hex << s << endl;\n    int left = nn - 1, right = 0;\n    vector<int> can({0});\n    while (left >= right) {\n        while ((s & (1 << left)) == 0)left--;\n        while ((s & (1 << right)) == 0)right++;\n        if (left > right) {\n            if (super.find(left) != super.end() && super.find(right) != super.end()) {\n                mn = min(mn, level);\n                mx = max(mx, level);\n                mp[s].insert(1);\n                return;\n            } else if (super.find(left) != super.end()) {\n                for (auto &num:can) {\n                    num += 1 << left;\n                }\n            } else if (super.find(right) != super.end()) {\n                for (auto &num:can) {\n                    num += 1 << right;\n                }\n            } else {\n                auto sz = can.size();\n                for (int i = 0; i < sz; ++i) {\n                    can.emplace_back(can[i] + (1 << right));\n                    can[i] += 1 << left;\n                }\n            }\n        } else if (left == right) {\n            for (auto &num:can) {\n                num += 1 << left;\n            }\n        }\n        left--;\n        right++;\n    }\n    for (auto &num:can) {\n        if (mp.find(num) == mp.end()) {\n            dfs(num, level + 1);\n        }\n        for (auto &p:mp[num]) {\n            if (p == -1)break;\n            mp[s].insert(p + level);\n        }\n    }\n\n}\n\nvector<int> earliestAndLatest(int n, int firstPlayer, int secondPlayer) {\n    mp[0].insert(-1);\n    nn = n;\n    super.insert(n - firstPlayer);\n    super.insert(n - secondPlayer);\n    dfs((1 << n) - 1, 1);\n    return {mn, mx};\n}\n```
[]