結果

問題 No.20 砂漠のオアシス
ユーザー konchanksukonchanksu
提出日時 2020-04-30 20:08:33
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 78,688 KB
最終ジャッジ日時 2023-08-22 15:06:29
合計ジャッジ時間 5,437 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,128 KB
testcase_01 AC 72 ms
71,644 KB
testcase_02 AC 80 ms
76,408 KB
testcase_03 AC 92 ms
76,548 KB
testcase_04 AC 120 ms
77,368 KB
testcase_05 AC 108 ms
77,812 KB
testcase_06 AC 130 ms
78,264 KB
testcase_07 WA -
testcase_08 AC 378 ms
77,972 KB
testcase_09 AC 444 ms
78,268 KB
testcase_10 AC 70 ms
71,264 KB
testcase_11 AC 72 ms
71,328 KB
testcase_12 AC 113 ms
77,368 KB
testcase_13 AC 126 ms
77,636 KB
testcase_14 AC 158 ms
77,768 KB
testcase_15 AC 133 ms
77,712 KB
testcase_16 WA -
testcase_17 AC 154 ms
77,760 KB
testcase_18 WA -
testcase_19 AC 256 ms
77,892 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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 i in range(N)] for j in range(N)]
memo[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 v <= memo[y][x]:
            continue

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

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