結果

問題 No.20 砂漠のオアシス
ユーザー konchanksukonchanksu
提出日時 2020-04-30 20:16:23
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,006 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 839,600 KB
最終ジャッジ日時 2023-08-22 15:25:13
合計ジャッジ時間 5,335 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,348 KB
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, V, Ox, Oy = map(int, input().split())
Ox -= 1
Oy -= 1
L = [[int(j) for j in input().split()] for i in range(N)]

memo = [[[0 for k in range(2)] for i in range(N)] for j in range(N)]
memo[0][0][0] = V
course = [(1, 0), (0, 1), (-1, 0), (0, -1)]

stack = [(0, 0, V, True)]

while stack:
    tmp = stack.pop()
    for i in course:
        y, x = tmp[0] + i[0], tmp[1] - i[1]
        if x < 0 or x >= N or y < 0 or y >= N:
            continue

        v = tmp[2] - L[y][x]
        
        if tmp[-1]:
            if v <= memo[y][x][0]:
                continue
        else:
            if v <= memo[y][x][1]:
                continue

        if x == N - 1 and y == N - 1:
            print('YES')
            exit()

        if y == Oy and x == Ox and tmp[-1]:
            memo[y][x][1] = v * 2
            stack.append((y, x, memo[y][x][1], False))
            
        else:
            memo[y][x][0] = v
            a = tmp[-1]
            stack.append((y, x, memo[y][x][0], a))
        
print('NO')
0