3 条题解

  • 0
    @ 2023-4-5 19:08:54
    #include<bits/stdc++.h>
    using namespace std;
    int a[10001],wsh[10001];
    int n;
    void dfs(int step) {
    	if(step==n+1) {
    		for(int i=1; i<=n; i++) {
    			cout<<a[i];
    		}
    		cout<<endl;
    		return ;
    	}
    	for(int i=1; i<=n; i++) {
    		if(wsh[i]==0) {
    			a[step]=i;
    			wsh[i]=1;
    			dfs(step+1);
    			wsh[i]=0;
    		}
    	}
    	return ;
    }
    int main() {
    	cin>>n;
    	dfs(1);
    	return 0;
    }
    

    信息

    ID
    1305
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    214
    已通过
    70
    上传者