結果

問題 No.20 砂漠のオアシス
コンテスト
ユーザー konchanksu
提出日時 2020-04-30 19:55:37
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 774 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 488 ms
コンパイル使用メモリ 20,572 KB
実行使用メモリ 15,452 KB
最終ジャッジ日時 2026-05-26 17:56:29
合計ジャッジ時間 9,585 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import queue

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)]

a = queue.Queue()
a.put((0, 0, V))

while a.qsize():
    tmp = a.get()
    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:
            memo[y][x] = v * 2
        else:
            memo[y][x] = v

        a.put((y, x, memo[y][x]))
        
print('NO')
0