3 条题解

  • 0
    @ 2026-9-12 21:08:16
    #include <iostream>
    using namespace std;
    int x;
    int a[1005];
    bool b[1005];
    void dfs(int step){
      if(step > x){
        for(int i = 1; i <= x; i ++){
          cout << "    " << a[i];  
        }
        cout << endl;
        return;  
      }  
      for(int i = 1; i <= x; i ++){
        if(!b[i]){
          a[step] = i;  
          b[i] = true;
          dfs(step + 1);
          b[i] = false;
        }
      }
    }
    int main() {
        cin >> x;
        dfs(1);
        return 0;
    }
    
    

    信息

    ID
    2275
    时间
    1000ms
    内存
    256MiB
    难度
    4
    标签
    递交数
    184
    已通过
    91
    上传者