# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28185 | 테에스뚜우웅우우우 (#71) | 도시와 비트코인 (FXCUP2_city) | Cpython 3 | 74 ms | 5 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
N,M = [int(i) for i in input().split()]
map = []
for i in range(M):
map.append([int(i) for i in input().split()])
dp = [[[0,0,0,0] for i in range(N)] for i in range(M)]
def find_road(index):
if index[0] >=M or index[0]<0 or index[1] >= N or index[1] <0 or map[index[0]][index[1]] == 0:
return -1
elif index[0] == M-1 and index[1] == N-1:
return 1
for via, value in enumerate(dp[index[0]][index[1]]):
if value == 0 :
if via == 0:
dp[index[0]][index[1]][0] = -2
dp[index[0]][index[1]][0] = find_road((index[0], index[1] + 1))
elif via == 1:
dp[index[0]][index[1]][1] = -2
dp[index[0]][index[1]][1] = find_road((index[0] + 1, index[1]))
elif via == 2:
dp[index[0]][index[1]][2] = -2
dp[index[0]][index[1]][2] = find_road((index[0], index[1] - 1))
else:
dp[index[0]][index[1]][3] = -2
dp[index[0]][index[1]][3] = find_road((index[0] - 1, index[1]))
return max(dp[index[0]][index[1]])
res = find_road((0,0))
if res == 1:
print('Yes')
else:
print('No')
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |