結果
問題 | No.2695 Warp Zone |
ユーザー |
![]() |
提出日時 | 2024-03-23 04:29:47 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 528 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 81,968 KB |
実行使用メモリ | 109,596 KB |
最終ジャッジ日時 | 2024-09-30 13:03:09 |
合計ジャッジ時間 | 5,061 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 24 |
ソースコード
h,w,n=map(int,input().split())o=[tuple(map(int,input().split())) for i in range(n)]e=[[] for i in range(n+2)]for i in range(n):a,b,c,d=o[i]e[n]+=[(i,abs(a-1)+abs(b-1))]e[i]+=[(n+1,abs(h-c)+abs(w-d))]for j in range(n):if i!=j:a2,b2,c2,d2=o[j]e[i]+=[(j,abs(c-a2)+abs(d-b2))]v=[h+w-2]*(n+2)v[n]=0q=[]from heapq import heappush,heappopheappush(q,(0,n))while len(q)>0:sc,sp=heappop(q)if sc>v[sp]:continuefor tp,tc in e[sp]:if v[tp]>sc+tc:v[tp]=sc+tcheappush(q,(v[tp],tp))print(q[n+1])