生活随笔
收集整理的這篇文章主要介紹了
2021.3.10阿里面试题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
'''
獲得第一行 n m k
'''
temp
=input()
templist
=temp
.split
(" ")
n
=int(templist
[0])
m
=int(templist
[1])
k
=int(templist
[2])
'''
獲得城市二維列表
'''
city
=[]
for i
in range(n
):temp
= input()templist
= list(temp
)if '@' in templist
: j
=templist
.index
('@')position
=[i
,j
]templist
[j
]='.'city
.append
(templist
)
'''
開始走路開車
'''
for i
in range(k
):temp
= input()if temp
== 'EAST':j
= position
[1] while 1:j
= j
+ 1 if j
>m
-1 : breakif city
[position
[0]][j
]=='#': breakposition
[1] = j
if temp
== 'WEST':j
= position
[1]while 1:j
= j
- 1 if j
< 0 : breakif city
[position
[0]][j
] == '#': breakposition
[1] = j
if temp
== 'SOUTH':i
= position
[0]while 1:i
= i
+ 1 if i
> n
-1: breakif city
[i
][position
[1]] == '#': breakposition
[0] = i
if temp
== 'NORTH':i
= position
[0]while 1:i
= i
- 1 if i
< 0 : breakif city
[i
][position
[1]] == '#': breakposition
[0] = iposition
[0] +=1
position
[1] +=1
print(position
)
時間不夠,還是太菜了,
總結
以上是生活随笔為你收集整理的2021.3.10阿里面试题的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。