vector<string> dfs(conststring &s, int b, constunordered_set<string> &d){ if (cache.count(b)) return cache[b]; int n = s.length(); if (b == n) return {""}; // 切记要返回一个空串不能是空集!! string w; for (int i = b; i < n; ++i) { w += s[i]; if (d.count(w)) { for (constauto &suffix : dfs(s, i + 1, d)) { cache[b].push_back(suffix.empty() ? w : w + ' ' + suffix); // 注意suffix有可能是空串!! } } } return cache[b]; }