题目描述
blablabla
算法1
(dfs)
dfs+python
python代码
def dfs(n, res, cur, seen):
if len(seen) == n:
print(' '.join(map(str,cur)))
return
for index in range(n):
if index not in seen:
cur.append(index+1)
seen.add(index)
dfs(n, res, cur, seen)
cur.pop()
seen.remove(index)
def main():
n = int(input())
seen = set()
res = []
dfs(n, res, [], seen)
main()