1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
a = [[0,1,0],[0,-1,0],[0,0,-1],[0,0,1]]
w = [0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,5,0,1,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0,1,0,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
load = []
ans = [0 for i in range(600)]
def dfs(deep,x,y,z):
if deep > 64 or w[z*100+y*10+x] == 0 or x >= 10 or y >= 10 or z >= 6 or x < 0 or y < 0 or z < 0:
return
# 正确输出
if w[z*100+y*10+x] == 3 and deep == 62:
for i in load:
print(i,end='')
print()
return
# 平面走
for i in range(4):
z += a[i][0]
y += a[i][1]
x += a[i][2]
if w[z*100+y*10+x] != 0 and ans[z*100+y*10+x] == 0:
if i == 0:
load.append('s')
elif i == 1:
load.append('w')
elif i == 2:
load.append('a')
elif i == 3:
load.append('d')
ans[z*100+y*10+x] = 1
dfs(deep+1,x,y,z)
ans[z * 100 + y * 10 + x] = 0
load.pop()
z -= a[i][0]
y -= a[i][1]
x -= a[i][2]
# 穿层
if z == 2 and y == 0:
tempz = 4
tempx = 9
if w[tempz*100+y*10+tempx] != 0 and ans[tempz * 100 + y * 10 + tempx] == 0:
load.append('W')
ans[tempz * 100 + y * 10 + tempx] = 1
dfs(deep+1,tempx,y,tempz)
ans[tempz * 100 + y * 10 + tempx] = 0
load.pop()
return
elif z == 3 and y == 9:
tempz = 5
tempx = 0
tempy = 7
if w[tempz*100+tempy*10+tempx] != 0 and ans[tempz*100+tempy*10+tempx] == 0:
load.append('S')
ans[tempz * 100 + tempy * 10 + tempx] = 1
dfs(deep+1,tempx,tempy,tempz)
ans[tempz * 100 + tempy * 10 + tempx] = 0
load.pop()
return
elif z == 4 and x == 0:
tempz = 3
tempy = 0
tempx = 2
if w[tempz*100+tempy*10+tempx] != 0 and ans[tempz*100+tempy*10+tempx] == 0:
load.append('A')
ans[tempz * 100 + tempy * 10 + tempx] = 1
dfs(deep+1,tempx,tempy,tempz)
ans[tempz * 100 + tempy * 10 + tempx] = 0
load.pop()
return
elif z == 5 and y == 0:
tempz = 0
tempy = 9
if w[tempz*100+tempy*10+x] != 0 and ans[tempz*100+tempy*10+x] == 0:
load.append('W')
ans[tempz * 100 + tempy * 10 + x] = 1
dfs(deep+1,x,tempy,tempz)
ans[tempz * 100 + tempy * 10 + x] = 0
load.pop()
return
elif z == 1 and x == 9:
tempz = 2
tempx = 0
if w[tempz*100+y*10+tempx] != 0 and ans[tempz*100+y*10+tempx] == 0:
load.append('D')
ans[tempz*100+y*10+tempx] = 1
dfs(deep+1,tempx,y,tempz)
ans[tempz * 100 + y * 10 + tempx] = 0
load.pop()
return
elif z == 0 and x == 9:
tempz = 1
tempx = 0
if w[tempz * 100 + y * 10 + tempx] != 0 and ans[tempz * 100 + y * 10 + tempx] == 0:
load.append('D')
ans[tempz * 100 + y * 10 + tempx] = 1
dfs(deep + 1, tempx, y, tempz)
ans[tempz * 100 + y * 10 + tempx] = 0
load.pop()
return
if __name__ == '__main__':
dfs(0,2,7,0)
|