8 条题解

  • 0
    @ 2024-4-7 21:50:43
    n = int(input())
    nums = [i for i in range(1,n+1)]
    res = []
    path = []
    used = [0]*n
    def dfs(nums,path,used,n):
        if len(path) == n:
            print(*path)
    
        for i in range(n):
            if used[i]:
                continue
            used[i] = 1
            path.append(nums[i])
            dfs(nums,path,used,n)
            path.pop()
            used[i] = 0
    
    dfs(nums,path,used,n)
    

    信息

    ID
    82
    时间
    2000ms
    内存
    512MiB
    难度
    5
    标签
    递交数
    399
    已通过
    155
    上传者