# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28185 | 테에스뚜우웅우우우 (#71) | The City and The Bitcoin (FXCUP2_city) | Cpython 3 | 74 ms | 5 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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... |