結果

問題 No.20 砂漠のオアシス
ユーザー konchanksukonchanksu
提出日時 2020-04-30 20:07:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 844 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 79,084 KB
最終ジャッジ日時 2023-08-22 15:03:22
合計ジャッジ時間 5,714 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,352 KB
testcase_01 AC 73 ms
71,240 KB
testcase_02 AC 81 ms
76,308 KB
testcase_03 AC 99 ms
76,488 KB
testcase_04 AC 113 ms
77,188 KB
testcase_05 AC 98 ms
76,684 KB
testcase_06 AC 122 ms
78,020 KB
testcase_07 WA -
testcase_08 AC 372 ms
78,116 KB
testcase_09 AC 431 ms
78,268 KB
testcase_10 AC 71 ms
71,096 KB
testcase_11 AC 71 ms
71,380 KB
testcase_12 AC 111 ms
77,124 KB
testcase_13 AC 114 ms
77,360 KB
testcase_14 AC 155 ms
77,440 KB
testcase_15 AC 128 ms
77,380 KB
testcase_16 WA -
testcase_17 AC 141 ms
77,440 KB
testcase_18 WA -
testcase_19 AC 241 ms
77,608 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
            stack.append((y, x, memo[y][x], tmp))
        
print('NO')
0