結果
問題 | No.2695 Warp Zone |
ユーザー | mutualns |
提出日時 | 2024-03-23 06:20:10 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,010 bytes |
コンパイル時間 | 318 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 431,364 KB |
最終ジャッジ日時 | 2024-03-23 06:20:38 |
合計ジャッジ時間 | 27,183 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,460 KB |
testcase_01 | AC | 39 ms
53,460 KB |
testcase_02 | AC | 40 ms
53,460 KB |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | AC | 97 ms
76,736 KB |
testcase_09 | AC | 1,187 ms
200,572 KB |
testcase_10 | AC | 43 ms
53,460 KB |
testcase_11 | AC | 700 ms
116,232 KB |
testcase_12 | AC | 1,347 ms
250,560 KB |
testcase_13 | AC | 40 ms
53,460 KB |
testcase_14 | AC | 1,540 ms
299,188 KB |
testcase_15 | AC | 1,133 ms
185,060 KB |
testcase_16 | AC | 577 ms
106,928 KB |
testcase_17 | AC | 919 ms
142,200 KB |
testcase_18 | AC | 1,685 ms
347,100 KB |
testcase_19 | AC | 87 ms
76,476 KB |
testcase_20 | AC | 1,611 ms
324,024 KB |
testcase_21 | AC | 1,497 ms
295,552 KB |
testcase_22 | AC | 1,048 ms
172,788 KB |
testcase_23 | AC | 1,291 ms
248,900 KB |
testcase_24 | AC | 38 ms
53,460 KB |
testcase_25 | AC | 38 ms
53,460 KB |
testcase_26 | AC | 37 ms
53,460 KB |
ソースコード
import heapq h,w,n=map(int,input().split()) wps=[] wpt=[] for i in range(n): a,b,c,d=map(int,input().split()) wps.append([a,b]) wpt.append([c,d]) def dist(x,y): return (abs(x[0]-y[0])+abs(x[1]-y[1])) d=[10**18]*(2+n*2) d[0]=0 g=[[] for _ in range(2+n*2)] for i in range(n): g[0].append([2*i+2,dist([1,1],wps[i])]) g[0].append([2*i+3,dist([1,1],wpt[i])]) g[0].append([1,dist([1,1],[h,w])]) for i in range(n): g[2*i+2].append([2*i+3,1]) g[2*i+3].append([2*i+2,dist(wps[i],wpt[i])]) g[2*i+2].append([1,dist(wps[i],[h,w])]) g[2*i+3].append([1,dist(wpt[i],[h,w])]) for j in range(n): if i==j: continue g[2*i+2].append([2*j+2,dist(wps[i],wps[j])]) g[2*i+2].append([2*j+3,dist(wps[i],wpt[j])]) g[2*i+3].append([2*j+2,dist(wpt[i],wps[j])]) g[2*i+3].append([2*j+3,dist(wpt[i],wpt[j])]) hq=[(0,0)] while hq: v,w=heapq.heappop(hq) if v>d[w]: continue for i,j in g[w]: if d[i]>v+j: d[i]=v+j heapq.heappush(hq,(v+j,i)) print(d[1])