結果
問題 | No.2328 Build Walls |
ユーザー | nikoro256 |
提出日時 | 2023-05-28 15:37:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 833 bytes |
コンパイル時間 | 370 ms |
コンパイル使用メモリ | 86,924 KB |
実行使用メモリ | 152,136 KB |
最終ジャッジ日時 | 2023-08-27 12:34:33 |
合計ジャッジ時間 | 27,724 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 78 ms
71,044 KB |
testcase_02 | AC | 79 ms
71,364 KB |
testcase_03 | AC | 78 ms
71,000 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 77 ms
71,160 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 78 ms
71,252 KB |
testcase_11 | AC | 78 ms
71,308 KB |
testcase_12 | WA | - |
testcase_13 | AC | 246 ms
89,228 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 99 ms
80,160 KB |
testcase_20 | WA | - |
testcase_21 | AC | 135 ms
89,084 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 173 ms
101,164 KB |
testcase_29 | WA | - |
testcase_30 | AC | 241 ms
102,048 KB |
testcase_31 | AC | 233 ms
102,052 KB |
testcase_32 | WA | - |
testcase_33 | TLE | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
ソースコード
import heapq ds=[[0,1],[1,1],[-1,1],[1,0],[-1,0],[0,-1],[1,-1],[-1,-1]] def daiku(): hq=[] for i in range(H-2): if A[i]!=-1: heapq.heappush(hq,[A[i],(i,0)]) high=[-1 for _ in range(W*H)] while len(hq)!=0: h,p=heapq.heappop(hq) if high[p[0]*W+p[1]]==-1: high[p[0]*W+p[1]]=h for dx,dy in ds: x,y=p x+=dx y+=dy if 0<=x<H-2 and 0<=y<W and A[x*W+y]!=-1 and high[x*W+y]==-1: heapq.heappush(hq,[h+A[x*W+y],(x,y)]) return high H,W=map(int,input().split()) A=[] for i in range(H-2): A+=list(map(int,input().split())) dist=daiku() ans=10**12 for i in range(H-2): if dist[i*W+W-1]!=-1: ans=min(ans,dist[i*W+W-1]) if ans>=10**12: print(-1) else: print(ans)