結果

問題 No.2695 Warp Zone
ユーザー PNJPNJ
提出日時 2024-03-22 22:55:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,344 KB
最終ジャッジ日時 2024-03-22 22:55:28
合計ジャッジ時間 3,325 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 WA -
testcase_02 AC 45 ms
53,460 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 76 ms
72,636 KB
testcase_10 AC 40 ms
53,460 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 38 ms
53,460 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 40 ms
53,460 KB
testcase_25 AC 41 ms
53,460 KB
testcase_26 AC 40 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
0