結果
| 問題 |
No.20 砂漠のオアシス
|
| コンテスト | |
| ユーザー |
tnodino
|
| 提出日時 | 2022-02-12 15:32:36 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 489 ms / 5,000 ms |
| コード長 | 931 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 13,568 KB |
| 最終ジャッジ日時 | 2024-06-28 17:40:22 |
| 合計ジャッジ時間 | 3,135 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
from heapq import heappop, heappush
def Dijkstra(H, W, L, sx, sy, gx, gy, V, Ox, Oy):
def _Dijkstra():
while heap:
C,x,y = heappop(heap)
C *= -1
if Cost[x][y] >= C:
continue
Cost[x][y] = C
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
heappush(heap, (-(C-L[nx][my]), nx, my))
INF = -1
dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]
Cost = [[INF] * W for _ in range(H)]
heap = []
heappush(heap, (-V, sx, sy))
_Dijkstra()
heappush(heap, (-(Cost[Ox][Oy]*2), Ox, Oy))
_Dijkstra()
return Cost[gx][gy]
N,V,Oy,Ox = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(N)]
if Dijkstra(N, N, L, 0, 0, N-1, N-1, V, Ox-1, Oy-1) > 0:
print('YES')
else:
print('NO')
tnodino