結果
| 問題 |
No.2695 Warp Zone
|
| コンテスト | |
| ユーザー |
PNJ
|
| 提出日時 | 2024-03-22 22:55:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 681 bytes |
| コンパイル時間 | 233 ms |
| コンパイル使用メモリ | 81,968 KB |
| 実行使用メモリ | 76,924 KB |
| 最終ジャッジ日時 | 2024-09-30 12:17:59 |
| 合計ジャッジ時間 | 2,775 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 19 |
ソースコード
import heapq
def f(s, n, edge):
dist = [float("Inf")]*n
dist[s] = 0
hq = [[0,s]]
heapq.heapify(hq)
while len(hq) > 0:
d,i = heapq.heappop(hq)
if dist[i] < d:
continue
for j,d_1 in edge[i]:
if dist[j] > (dist[i] + d_1):
dist[j] = dist[i] + d_1
heapq.heappush(hq, [dist[j],j])
return dist
H,W,N = map(int,input().split())
s = 0
g = 2*N + 1
G = [[] for i in range(2*N+2)]
G[s].append((g,H+W-2))
for i in range(1,N+1):
a,b,c,d = map(int,input().split())
u,v = i,i+N
G[0].append((u,a+b-2))
G[u].append((v,1))
G[v].append((g,H+W-c-d))
dist = f(0,2*N+2,G)
print(dist[g])
PNJ