結果

問題 No.20 砂漠のオアシス
ユーザー tnodinotnodino
提出日時 2022-02-11 06:31:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 83,340 KB
最終ジャッジ日時 2023-09-09 06:48:21
合計ジャッジ時間 4,528 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,608 KB
testcase_01 AC 97 ms
71,516 KB
testcase_02 AC 94 ms
71,468 KB
testcase_03 AC 120 ms
77,644 KB
testcase_04 AC 121 ms
77,800 KB
testcase_05 AC 192 ms
80,668 KB
testcase_06 AC 125 ms
77,544 KB
testcase_07 AC 241 ms
83,340 KB
testcase_08 AC 144 ms
78,440 KB
testcase_09 AC 177 ms
79,912 KB
testcase_10 WA -
testcase_11 AC 93 ms
71,560 KB
testcase_12 WA -
testcase_13 AC 115 ms
77,624 KB
testcase_14 AC 121 ms
77,736 KB
testcase_15 AC 118 ms
77,652 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 125 ms
77,692 KB
testcase_20 AC 113 ms
77,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def bfs(H, W, L, sx, sy, gx, gy, V, Ox, Oy):
    def _bfs():
        while Queue:
            x,y = Queue.popleft()
            for i in range(len(dx)):
                nx,my = x + dx[i], y + dy[i]
                if nx < 0 or H <= nx or my < 0 or W <= my:
                    continue
                if Cost[nx][my] < Cost[x][y] - L[nx][my]:
                    Cost[nx][my] = Cost[x][y] - L[nx][my]
                    Queue.append((nx, my))
    INF = -10
    dx = [0, 0, -1, 1]
    dy = [-1, 1, 0, 0]
    Cost = [[INF] * W for _ in range(H)]
    Cost[sx][sy] = V
    Queue = deque()
    Queue.append((sx, sy))
    _bfs()
    Cost[Ox][Oy] *= 2
    Queue.append((Ox, Oy))
    _bfs()
    return Cost[gx][gy]

N,V,Ox,Oy = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(N)]
if bfs(N, N, L, 0, 0, N-1, N-1, V, Ox-1, Oy-1) > 0:
    print('YES')
else:
    print('NO')
0