3 条题解

  • 0
    @ 2025-3-8 15:02:39

    我再来发一遍

    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+5,INF=0x3f3f3f3f;
    typedef long long LL;
    string a;
    int main()
    {
    	cin>>a;
    	do{
    		cout<<a<<endl;
    	}while(next_permutation(a.begin(),a.end()));
    	return 0;
    }
    
    • 0
      @ 2025-1-29 21:08:34
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
          string a;
          cin>>a;
          sort(a.begin(),a.end());
          do cout<<a<<endl;
          while (next_permutation(a.begin(), a.end()));
          return 0;
      }
      
      • @ 2025-1-29 21:09:35

        用sort和next_permutation就能实现全排列(STL函数真好用!)

    • -1
      @ 2024-11-10 19:49:12

      #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include <complex.h> #include <fenv.h> #include <inttypes.h> #include <stdbool.h> #include <stdint.h> #include <tgmath.h> #include <windows.h> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; char a[N] , box[N]; bool v[N]; int len; void dfs(int step){ if(step == len){ cout << box << endl; return; } for(int i = 0;i < len;i++){ if(!v[i]){ v[i] = 1; box[step] = a[i]; dfs(step + 1); v[i] = 0; } } } int main() { cin >> a; len = strlen(a); dfs(0); return 0; }

      • 1

      信息

      ID
      1239
      时间
      1000ms
      内存
      128MiB
      难度
      5
      标签
      递交数
      64
      已通过
      25
      上传者