結果
問題 | No.20 砂漠のオアシス |
ユーザー | tnodino |
提出日時 | 2022-02-12 15:32:36 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 407 ms / 5,000 ms |
コード長 | 931 bytes |
コンパイル時間 | 92 ms |
コンパイル使用メモリ | 10,872 KB |
実行使用メモリ | 11,188 KB |
最終ジャッジ日時 | 2023-09-11 03:08:56 |
合計ジャッジ時間 | 2,894 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
8,044 KB |
testcase_01 | AC | 18 ms
8,060 KB |
testcase_02 | AC | 18 ms
8,028 KB |
testcase_03 | AC | 28 ms
8,024 KB |
testcase_04 | AC | 36 ms
8,052 KB |
testcase_05 | AC | 407 ms
11,188 KB |
testcase_06 | AC | 46 ms
8,816 KB |
testcase_07 | AC | 323 ms
10,272 KB |
testcase_08 | AC | 96 ms
9,168 KB |
testcase_09 | AC | 270 ms
9,760 KB |
testcase_10 | AC | 17 ms
8,152 KB |
testcase_11 | AC | 17 ms
8,052 KB |
testcase_12 | AC | 27 ms
8,048 KB |
testcase_13 | AC | 25 ms
8,144 KB |
testcase_14 | AC | 41 ms
8,168 KB |
testcase_15 | AC | 36 ms
8,252 KB |
testcase_16 | AC | 63 ms
8,544 KB |
testcase_17 | AC | 52 ms
8,032 KB |
testcase_18 | AC | 53 ms
8,608 KB |
testcase_19 | AC | 61 ms
8,208 KB |
testcase_20 | AC | 21 ms
8,080 KB |
ソースコード
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')