結果

問題 No.20 砂漠のオアシス
ユーザー konchanksukonchanksu
提出日時 2020-04-30 19:55:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 774 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 9,932 KB
最終ジャッジ日時 2023-08-22 14:23:11
合計ジャッジ時間 8,576 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
9,040 KB
testcase_01 AC 25 ms
9,180 KB
testcase_02 AC 25 ms
9,168 KB
testcase_03 AC 135 ms
9,116 KB
testcase_04 AC 451 ms
9,156 KB
testcase_05 AC 165 ms
9,476 KB
testcase_06 AC 623 ms
9,932 KB
testcase_07 TLE -
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 #

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