結果
問題 |
No.20 砂漠のオアシス
|
ユーザー |
![]() |
提出日時 | 2022-02-12 15:18:43 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 908 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 18,720 KB |
最終ジャッジ日時 | 2024-06-28 17:26:18 |
合計ジャッジ時間 | 8,488 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 TLE * 1 -- * 13 |
ソースコード
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) 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')