1 条题解

  • 0
    @ 2023-5-3 18:26:51
    #include<bits/stdc++.h>
    
    using namespace std;
    
    const int N=23;
    int path[N];
    int st[N];
    int n,r;
    
    void search (int u){
        if(u==r){
            for(int i=0;i<u;i++)
            {printf("%3d",path[i]);
            }
            cout<<endl;
        }
        for(int i=1;i<=n;i++){
            if(!st[i] && i>path[u-1]){
                path[u]=i;
                st[i]=true;
                search(u+1);
                st[i]=false;
            }
        }
    }
    
    
    int main()
    {
        cin>>n>>r;
        search(0);
        return 0;
        
    }
    
    • 1

    信息

    ID
    321
    时间
    1000ms
    内存
    128MiB
    难度
    8
    标签
    递交数
    16
    已通过
    8
    上传者