lh_lcg @ 2024-09-10 13:10:02
rp = [
lambda x, y: (x, y+1),
lambda x, y: (x-1, y),
lambda x, y: (x, y-1),
lambda x, y: (x+1, y)
]
def yidong():
x = p[-1][0]
y = p[-1][1]
for o in rp:
l = o(x, y)
l = list(l)
if l in q:
continue
else:
a = l[0]
b = l[1]
if 0 <= a < n and 0 <= b < m:
if mo[a][b] == '.':
q.append(l)
p.append(l)
break
else:
continue
else:
p.pop()
mo = []
ol = []
q = [] # 标记
p = [[0, 0]] # 路线
n, m = map(int, input().split())
for i in range(n):
j = input()
g = [a for a in j]
mo.append(g)
while p[-1] != [n-1, m-1]:
yidong()
if len(p) < 2:
print('No')
break
else:
print('Yes')