#include using namespace std; const int N = 26; // acdaccdd unordered_set S; //有哪些字符 bool st[N]; //是不是使过了 string res; //结果,字典序最小 string s; //原始串 string t; void dfs(int u) { //出口 if (u == s.size()) { if (t.size() == S.size()) if (t < res) res = t; // t> s; //去重形成一个集合 for (int i = 0; i < s.size(); i++) S.insert(s[i]); //深搜 dfs(0); //输出 cout << res << endl; return 0; }