1 条题解

  • 0
    @ 2025-5-7 0:27:34

    解题思路

    先进行排序,使得初始字符串字典序最小(使用sortsort函数),再使用STLSTL全排列库函数nextpermutationnext_permutation就可以轻松解决

    标程

    #include <iostream>
    #include <algorithm>
    #include <string>
    
    using namespace std;
    
    int main() {
        string s;
        cin >> s;
        sort(s.begin(), s.end());  // 排序使字符串按字典序最小开始
        do {
            cout << s << endl;
        } while (next_permutation(s.begin(), s.end()));
        return 0;
    }
    
    • 1

    信息

    ID
    732
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    4
    已通过
    1
    上传者