题解 | #火车进站#
火车进站
https://www.nowcoder.com/practice/97ba57c35e9f4749826dc3befaeae109
a = int(input().strip())
b = list(map(str,input().strip().split(" ")))
resault = []
def dfs(input1,wait1,output1):
if len(output1) == a:
resault.append(output1)
if input1:
dfs(input1[1:],wait1+[input1[0]],output1)
if wait1:
dfs(input1,wait1[:-1],output1+wait1[-1])
dfs(b,[],'')
for i in sorted(resault):
for j in i:
print(j,end=" ")
print()
